Total Complexity | 6 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 87.5% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class PathFinder implements PathFinderInterface |
||
11 | { |
||
12 | /** @var array<string,array<int,string>> */ |
||
13 | private static array $cache = []; |
||
14 | |||
15 | 23 | /** |
|
16 | * @return string[] |
||
17 | 23 | */ |
|
18 | 18 | public function matchingPattern(string $pattern): array |
|
19 | { |
||
20 | if ($pattern === '') { |
||
21 | 23 | return []; |
|
22 | } |
||
23 | 23 | ||
24 | if (isset(self::$cache[$pattern])) { |
||
25 | return self::$cache[$pattern]; |
||
26 | } |
||
27 | |||
28 | $this->ensureGlobBraceIsDefined(); |
||
29 | |||
30 | return self::$cache[$pattern] = glob($pattern, GLOB_BRACE) ?: []; |
||
31 | 23 | } |
|
32 | |||
33 | 23 | /** |
|
34 | * Note: The GLOB_BRACE flag is not available on some non-GNU systems, like Solaris or Alpine Linux. |
||
35 | * |
||
36 | * @see https://www.php.net/manual/en/function.glob.php |
||
37 | */ |
||
38 | private function ensureGlobBraceIsDefined(): void |
||
42 | } |
||
43 | } |
||
45 |