Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | abstract class PathSanitizer |
||
6 | { |
||
7 | /** |
||
8 | * Ajusta uma string de caminho para |
||
9 | * |
||
10 | * @param string $path |
||
11 | * @return string |
||
12 | */ |
||
13 | public static function sanitize(string $path) : string |
||
14 | { |
||
15 | $path = self::replaceSeparator($path); |
||
16 | $path = self::removeDoubleSlashes($path); |
||
17 | $path = self::replaceInverseSlashes($path); |
||
18 | |||
19 | return $path; |
||
20 | } |
||
21 | |||
22 | private static function replaceSeparator(string $path) : string |
||
23 | { |
||
24 | $anti = (DS == '/') ? '\\' : '/'; |
||
25 | |||
26 | return str_replace($anti, DS, $path); |
||
27 | } |
||
28 | |||
29 | private static function removeDoubleSlashes(string $path) : string |
||
34 | } |
||
35 | |||
36 | private static function replaceInverseSlashes(string $path) : string |
||
45 | } |
||
46 | } |