Total Complexity | 9 |
Total Lines | 91 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class Path |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * |
||
11 | * Add a trailing slash to the end of a string (if it doesn't exist) |
||
12 | * |
||
13 | * @param $path |
||
14 | * |
||
15 | * @return string |
||
16 | */ |
||
17 | 3 | public static function withEndingSlash($path): string |
|
18 | { |
||
19 | 3 | return rtrim($path, '/') . '/'; |
|
20 | } |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * Remove the trailing slash from a string (if exists). |
||
25 | * |
||
26 | * @param $path |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | 3 | public static function withoutEndingSlash($path): string |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * Remove the leading slash of a string (if exists). |
||
38 | * |
||
39 | * @param $path |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 3 | public static function withoutStartingSlash($path): string |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * |
||
56 | * Add a leading slash to a string (if it doesn't exist) |
||
57 | * |
||
58 | * @param $path |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public static function withStartingSlash($path): string |
||
63 | { |
||
64 | 3 | return '/' . ltrim($path, '/'); |
|
65 | } |
||
66 | 3 | ||
67 | 3 | /** |
|
68 | 3 | * |
|
69 | 3 | * Remove dot segments from paths. |
|
70 | * |
||
71 | 3 | * @link https://tools.ietf.org/html/rfc3986#section-5.2.4 |
|
72 | 3 | * @link https://stackoverflow.com/a/21486848/1234452 |
|
73 | * |
||
74 | * @param $path |
||
75 | 3 | * @return string |
|
76 | */ |
||
77 | 3 | public static function canonical($path): string |
|
97 | } |
||
98 | } |
||
99 |