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