| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 93.33% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class FilesPathService |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param string[] $patterns |
||
| 11 | * @return string[] |
||
| 12 | */ |
||
| 13 | 14 | public static function getPathToFiles(array $patterns): array |
|
| 14 | { |
||
| 15 | 14 | $pathToFiles = [[]]; |
|
| 16 | 14 | foreach ($patterns as $pattern) { |
|
| 17 | 14 | if (is_file($pattern)) { |
|
| 18 | 10 | $pathToFiles[] = [$pattern]; |
|
| 19 | } else { |
||
| 20 | 12 | $pathToFiles[] = self::globRecursive($pattern); |
|
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | 14 | $pathToFiles = array_merge(...$pathToFiles); |
|
| 25 | 14 | $pathToFiles = str_replace('\\', '/', $pathToFiles); |
|
| 26 | |||
| 27 | 14 | return array_unique($pathToFiles); |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $pattern |
||
| 32 | * @return string[] |
||
| 33 | * |
||
| 34 | * @link https://www.php.net/manual/en/function.glob.php#106595 |
||
| 35 | */ |
||
| 36 | 12 | private static function globRecursive(string $pattern): array |
|
| 46 | } |
||
| 47 | } |
||
| 48 |