1 | <?php |
||
7 | final class Path |
||
8 | { |
||
9 | /** |
||
10 | * Combine any amount of strings into a path. |
||
11 | * |
||
12 | * @param string|array ...$paths One or as many parameters as you need. Both strings and arrays of strings can be mixed. |
||
13 | * |
||
14 | * @return string The combined paths. Note that the directory separators will be changed to reflect the local system. |
||
15 | */ |
||
16 | public static function combine(...$paths) |
||
33 | |||
34 | /** |
||
35 | * Localize directory separators for any file path according to current environment. |
||
36 | * |
||
37 | * @param string $path |
||
38 | * @param string $directorySeparator |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public static function localize($path, $directorySeparator = DIRECTORY_SEPARATOR) |
||
53 | |||
54 | /** |
||
55 | * Contains returns true if a base path contains a needle. |
||
56 | * |
||
57 | * Note that `realpath` is used on both base and needle: they need to exist or false is returned. |
||
58 | * |
||
59 | * Use this for avoiding directory traversal outside of a base path. |
||
60 | * |
||
61 | * @param string $base Path to base directory. |
||
62 | * @param string $needle Needle that must exist within the base directory. |
||
63 | * |
||
64 | * @return bool True if both exist and needle does not escape the base folder. |
||
65 | */ |
||
66 | public static function contains($base, $needle) |
||
75 | |||
76 | /** |
||
77 | * isAbsolute checks for an absolute UNIX, Windows or scheme:// path. |
||
78 | * |
||
79 | * Note that paths containing parent dots (`..`) can still be considered absolute. |
||
80 | * |
||
81 | * @param string $path |
||
82 | * |
||
83 | * @return bool True if the path is absolute i.e. it should be safe to append a relative path to it. |
||
84 | */ |
||
85 | public static function isAbsolute($path) |
||
95 | |||
96 | private static function extractScheme(&$parts) { |
||
110 | } |
||
111 |