| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 71 | 3 | public static function canonical($path): string |
|
| 72 | 3 | { |
|
| 73 | $path = explode('/', $path); |
||
| 74 | $stack = []; |
||
| 75 | 3 | foreach ($path as $seg) { |
|
| 76 | if ($seg == '..') { |
||
| 77 | 3 | // Ignore this segment, remove last segment from stack |
|
| 78 | array_pop($stack); |
||
| 79 | continue; |
||
| 80 | 3 | } |
|
| 81 | |||
| 82 | if ($seg == '.') { |
||
| 83 | 3 | // Ignore this segment |
|
| 84 | continue; |
||
| 85 | } |
||
| 86 | |||
| 87 | $stack[] = $seg; |
||
| 88 | } |
||
| 89 | |||
| 90 | return implode('/', $stack); |
||
| 91 | } |
||
| 93 |