1 | <?php |
||
20 | class PathHelper |
||
21 | { |
||
22 | /** |
||
23 | * Convert path separator to the system's default separator |
||
24 | * |
||
25 | * For example: |
||
26 | * root\\foo/bar\ becomes root: |
||
27 | * - \\foo\\bar on Windows and |
||
28 | * - /root/foo/bar on Linux |
||
29 | * |
||
30 | * @param string $path |
||
31 | * @return string |
||
32 | */ |
||
33 | 44 | public function normalizePathSeparator(string $path): string |
|
38 | |||
39 | /** |
||
40 | * Extract the the filename from a path |
||
41 | * |
||
42 | * Example: from /foo/bar/file.ext will result file.ext |
||
43 | * |
||
44 | * @param string $file_path |
||
45 | * @return string |
||
46 | */ |
||
47 | 43 | public function extractFilenameFromPath(string $file_path): string |
|
52 | |||
53 | /** |
||
54 | * Split a filename into an array containing the name and extension |
||
55 | * Example: |
||
56 | * file.ext -> [file, ext] |
||
57 | * .htaccess -> ['', htaccess] |
||
58 | * name -> [name, ''] |
||
59 | * |
||
60 | * @param string $filename |
||
61 | * @return array |
||
62 | */ |
||
63 | 44 | public function splitFilename(string $filename): array |
|
79 | } |
||
80 |