$changes Changes. * @return array{change: array{time: int, kind: string, type: string, slug: string, name: string, from: string|null, to: string|null}, reason: string}|null */ public static function match( ?string $component, int $first_seen, array $changes ): ?array { $best_same = null; $best_timing = null; foreach ( $changes as $change ) { if ( ! in_array( $change['kind'], self::KINDS, true ) || $change['time'] > $first_seen ) { continue; } $age = $first_seen - $change['time']; $name = 'core' === $change['type'] ? 'core' : $change['type'] . ':' . $change['slug']; if ( null !== $component && $name === $component && $age <= self::COMPONENT_WINDOW ) { if ( null === $best_same || $change['time'] > $best_same['time'] ) { $best_same = $change; } } elseif ( $age <= self::TIMING_WINDOW && ( null === $best_timing || $change['time'] > $best_timing['time'] ) ) { $best_timing = $change; } } if ( null !== $best_same ) { return array( 'change' => $best_same, 'reason' => 'same_component', ); } if ( null !== $best_timing ) { return array( 'change' => $best_timing, 'reason' => 'timing', ); } return null; } }