Conditions | 6 |
Paths | 5 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | protected function sanitizePath($path) |
||
36 | { |
||
37 | if (\is_array($path)) { |
||
|
|||
38 | return array_map([$this, 'sanitizePath'], $path); |
||
39 | } |
||
40 | |||
41 | $path = iconv($encoding = 'UTF-8', "$encoding//IGNORE//TRANSLIT", $path); |
||
42 | |||
43 | $parts = explode('/', $path); |
||
44 | $safe = []; |
||
45 | foreach ($parts as $part) { |
||
46 | if (empty($part) || ('.' === $part)) { |
||
47 | continue; |
||
48 | } |
||
49 | |||
50 | if ('..' === $part) { |
||
51 | array_pop($safe); |
||
52 | |||
53 | continue; |
||
54 | } |
||
55 | |||
56 | $safe[] = $part; |
||
57 | } |
||
58 | |||
59 | return implode(\DIRECTORY_SEPARATOR, $safe); |
||
60 | } |
||
75 |