| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.0119 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 12 | public static function realpath(string $path): string |
|
| 18 | { |
||
| 19 | 12 | $parts = explode('/', self::normalize($path)); |
|
| 20 | 12 | $out = []; |
|
| 21 | 12 | foreach ($parts as $part) { |
|
| 22 | 12 | if ($part === '.') { |
|
| 23 | continue; |
||
| 24 | } |
||
| 25 | 12 | if ($part === '..') { |
|
| 26 | 8 | array_pop($out); |
|
| 27 | 8 | continue; |
|
| 28 | } |
||
| 29 | 12 | $out[] = $part; |
|
| 30 | } |
||
| 31 | |||
| 32 | 12 | return implode('/', $out); |
|
| 33 | } |
||
| 46 |