1 | <?php |
||
27 | final class Url |
||
28 | { |
||
29 | /** |
||
30 | * Turns a URL into a relative path. |
||
31 | * |
||
32 | * The result is a canonical path. This class is using functionality of Path class. |
||
33 | * |
||
34 | * @see Path |
||
35 | * |
||
36 | * @param string $url A URL to make relative. |
||
37 | * @param string $baseUrl A base URL. |
||
38 | * |
||
39 | * @return string |
||
40 | * |
||
41 | * @throws InvalidArgumentException If the URL and base URL does |
||
42 | * not match. |
||
43 | */ |
||
44 | 61 | public static function makeRelative($url, $baseUrl) |
|
73 | |||
74 | /** |
||
75 | * Splits a URL into its host and the path. |
||
76 | * |
||
77 | * ```php |
||
78 | * list ($root, $path) = Path::split("http://example.com/webmozart") |
||
79 | * // => array("http://example.com", "/webmozart") |
||
80 | * |
||
81 | * list ($root, $path) = Path::split("http://example.com") |
||
82 | * // => array("http://example.com", "") |
||
83 | * ``` |
||
84 | * |
||
85 | * @param string $url The URL to split. |
||
86 | * |
||
87 | * @return string[] An array with the host and the path of the URL. |
||
88 | * |
||
89 | * @throws InvalidArgumentException If $url is not a URL. |
||
90 | */ |
||
91 | 56 | private static function split($url) |
|
111 | } |
||
112 |