Total Complexity | 8 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | abstract class Check |
||
18 | { |
||
19 | /** |
||
20 | * Is given path absolute? |
||
21 | * |
||
22 | * @param string $path |
||
23 | * @return bool |
||
24 | */ |
||
25 | 6 | public static function isAbsolutePath(string $path) : bool |
|
26 | { |
||
27 | // path already absolute? |
||
28 | 6 | if (substr($path, 0, 1) === '/') { |
|
29 | 1 | return true; |
|
30 | } |
||
31 | 5 | if (self::isStream($path)) { |
|
32 | 1 | return true; |
|
33 | } |
||
34 | 4 | if (self::isAbsoluteWindowsPath($path)) { |
|
35 | 2 | return true; |
|
36 | } |
||
37 | 2 | return false; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Is given path a stream reference? |
||
42 | * |
||
43 | * @param string $path |
||
44 | * @return bool |
||
45 | */ |
||
46 | 5 | public static function isStream(string $path): bool |
|
47 | { |
||
48 | 5 | return strpos($path, '://') !== false; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Is given path an absolute windows path? |
||
53 | * |
||
54 | * matches the following on Windows: |
||
55 | * - \\NetworkComputer\Path |
||
56 | * - \\.\D: |
||
57 | * - \\.\c: |
||
58 | * - C:\Windows |
||
59 | * - C:\windows |
||
60 | * - C:/windows |
||
61 | * - c:/windows |
||
62 | * |
||
63 | * @param string $path |
||
64 | * @return bool |
||
65 | */ |
||
66 | 4 | public static function isAbsoluteWindowsPath(string $path) : bool |
|
69 | } |
||
70 | } |
||
71 |