Skip to content

Commit

Permalink
Add earlier array cast
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 19, 2024
1 parent be16f73 commit f0b85d9
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@ public static function handle(string $directory, string|array|false $matchExtens
}

if ($matchExtensions !== false) {
$finder->name(static::buildFileExtensionPattern($matchExtensions));
$finder->name(static::buildFileExtensionPattern((array) $matchExtensions));
}

return collect($finder)->map(function (SplFileInfo $file): string {
return Hyde::pathToRelative($file->getPathname());
})->sort()->values();
}

/** @param string|array<string> $extensions */
protected static function buildFileExtensionPattern(string|array $extensions): string
/** @param array<string> $extensions */
protected static function buildFileExtensionPattern(array $extensions): string
{
$extensions = (array) $extensions;

// Normalize array by splitting any CSV strings within
$extensions = array_merge(...array_map(function ($item) {
return array_map('trim', explode(',', $item));
Expand Down

0 comments on commit f0b85d9

Please sign in to comment.