Conditions | 7 |
Paths | 7 |
Total Lines | 23 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | 2 | public static function fitsPattern($path, $pattern) |
|
11 | { |
||
12 | 2 | $path = explode('/', $path); |
|
13 | 2 | $pattern = explode('/', $pattern); |
|
14 | |||
15 | 2 | foreach ($path as $i => $item) { |
|
16 | 2 | if (!isset($pattern[$i])) { |
|
17 | 2 | return false; |
|
18 | } |
||
19 | 2 | $pitem = $pattern[$i]; |
|
20 | 2 | if ($pitem === '...') { |
|
21 | 2 | return true; |
|
22 | } |
||
23 | 2 | if (($pitem === '*') || $pitem === $item) { |
|
24 | 2 | continue; |
|
25 | } else { |
||
26 | 2 | return false; |
|
27 | } |
||
28 | } |
||
29 | 2 | if (count($pattern) > count($path)) { |
|
30 | 2 | return false; |
|
31 | } |
||
32 | 2 | return true; |
|
33 | } |
||
45 | } |