1 | <?php |
||
17 | class Path |
||
18 | { |
||
19 | /** |
||
20 | * Date placeholder replacement. |
||
21 | * Replaces %{somevalue} with date({somevalue}). |
||
22 | * |
||
23 | * @param string $string |
||
24 | * @param mixed <integer|null> $time |
||
25 | * @return string |
||
26 | */ |
||
27 | 74 | public static function replaceDatePlaceholders($string, $time = null) |
|
38 | |||
39 | /** |
||
40 | * Does a given string contain a date placeholder. |
||
41 | * |
||
42 | * @param string $string |
||
43 | * @return bool |
||
44 | */ |
||
45 | 47 | public static function isContainingPlaceholder($string) |
|
49 | |||
50 | /** |
||
51 | * Replaces %TARGET_DIR% and %TARGET_FILE% in given string. |
||
52 | * |
||
53 | * @param string $string |
||
54 | * @param string $target |
||
55 | * @return string |
||
56 | */ |
||
57 | 4 | public static function replaceTargetPlaceholders($string, $target) |
|
64 | |||
65 | /** |
||
66 | * Create a regex that matches the raw path considering possible date placeholders. |
||
67 | * |
||
68 | * @param string $stringWithDatePlaceholders |
||
69 | * @return string |
||
70 | */ |
||
71 | 14 | public static function datePlaceholdersToRegex($stringWithDatePlaceholders) |
|
76 | |||
77 | /** |
||
78 | * Determine if the path has a trailing slash. |
||
79 | * |
||
80 | * @param string $string |
||
81 | * @return bool |
||
82 | */ |
||
83 | 28 | public static function hasTrailingSlash(string $string) : bool |
|
87 | |||
88 | /** |
||
89 | * Adds trailing slash to a string/path if not already there. |
||
90 | * |
||
91 | * @param string $string |
||
92 | * @return string |
||
93 | */ |
||
94 | 21 | public static function withTrailingSlash($string) |
|
98 | |||
99 | /** |
||
100 | * Removes the trailing slash from a string/path. |
||
101 | * |
||
102 | * @param string $string |
||
103 | * @return string |
||
104 | */ |
||
105 | 6 | public static function withoutTrailingSlash($string) |
|
109 | |||
110 | /** |
||
111 | * Determine if the path has a leading slash. |
||
112 | * |
||
113 | * @param string $string |
||
114 | * @return bool |
||
115 | */ |
||
116 | 24 | public static function hasLeadingSlash(string $string) : bool |
|
120 | |||
121 | /** |
||
122 | * Adds leading slash to a string/path if not already there. |
||
123 | * |
||
124 | * @param string $string |
||
125 | * @return string |
||
126 | */ |
||
127 | 6 | public static function withLeadingSlash($string) |
|
131 | |||
132 | /** |
||
133 | * Removes the leading slash from a string/path. |
||
134 | * |
||
135 | * @param string $string |
||
136 | * @return string |
||
137 | */ |
||
138 | 1 | public static function withoutLeadingSlash($string) |
|
142 | |||
143 | /** |
||
144 | * Is given path absolute. |
||
145 | * |
||
146 | * @param string $path |
||
147 | * @return bool |
||
148 | */ |
||
149 | 49 | public static function isAbsolutePath($path) : bool |
|
175 | |||
176 | /** |
||
177 | * Is given path an absolute windows path. |
||
178 | * |
||
179 | * @param string $path |
||
180 | * @return bool |
||
181 | */ |
||
182 | 3 | public static function isAbsoluteWindowsPath($path) : bool |
|
186 | |||
187 | /** |
||
188 | * Converts a path to an absolute one if necessary relative to a given base path. |
||
189 | * |
||
190 | * @param string $path |
||
191 | * @param string $base |
||
192 | * @param boolean $useIncludePath |
||
193 | * @return string |
||
194 | */ |
||
195 | 46 | public static function toAbsolutePath(string $path, string $base, bool $useIncludePath = false) : string |
|
211 | |||
212 | /** |
||
213 | * Return list of directories in a given path. |
||
214 | * |
||
215 | * @param string $path |
||
216 | * @return array |
||
217 | */ |
||
218 | 15 | public static function getDirectoryList(string $path) : array |
|
226 | |||
227 | /** |
||
228 | * Returns directory depth of a given path. |
||
229 | * |
||
230 | * @param string $path |
||
231 | * @return int |
||
232 | */ |
||
233 | 10 | public static function getPathDepth(string $path) : int |
|
237 | } |
||
238 |