$this->dateTime($value), $timestamps))); if ($filtered === []) { return null; } usort($filtered, static fn (DateTimeInterface $left, DateTimeInterface $right): int => $left < $right ? 1 : -1); return $filtered[0]; } protected function dateTime(mixed $value): ?Carbon { if ($value instanceof Carbon) { return $value; } if ($value instanceof DateTimeInterface) { return Carbon::instance($value); } if (is_string($value) && trim($value) !== '') { return Carbon::parse($value); } return null; } protected function absoluteUrl(?string $url): ?string { $value = trim((string) $url); if ($value === '') { return null; } if (Str::startsWith($value, ['http://', 'https://'])) { return $value; } return url($value); } protected function image(?string $url, ?string $title = null): ?SitemapImage { $absolute = $this->absoluteUrl($url); if ($absolute === null) { return null; } return new SitemapImage($absolute, $title !== '' ? $title : null); } /** * @param array $images * @return list */ protected function images(array $images): array { return array_values(array_filter($images, static fn (mixed $image): bool => $image instanceof SitemapImage)); } }