1 | <?php |
||
31 | class FacebookUrlManipulator |
||
32 | { |
||
33 | /** |
||
34 | * Remove params from a URL. |
||
35 | * |
||
36 | * @param string $url The URL to filter. |
||
37 | * @param array $paramsToFilter The params to filter from the URL. |
||
38 | * |
||
39 | * @return string The URL with the params removed. |
||
40 | */ |
||
41 | public static function removeParamsFromUrl($url, array $paramsToFilter) |
||
68 | |||
69 | /** |
||
70 | * Gracefully appends params to the URL. |
||
71 | * |
||
72 | * @param string $url The URL that will receive the params. |
||
73 | * @param array $newParams The params to append to the URL. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public static function appendParamsToUrl($url, array $newParams = []) |
||
99 | |||
100 | /** |
||
101 | * Returns the params from a URL in the form of an array. |
||
102 | * |
||
103 | * @param string $url The URL to parse the params from. |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | public static function getParamsAsArray($url) |
||
118 | |||
119 | /** |
||
120 | * Adds the params of the first URL to the second URL. |
||
121 | * |
||
122 | * Any params that already exist in the second URL will go untouched. |
||
123 | * |
||
124 | * @param string $urlToStealFrom The URL harvest the params from. |
||
125 | * @param string $urlToAddTo The URL that will receive the new params. |
||
126 | * |
||
127 | * @return string The $urlToAddTo with any new params from $urlToStealFrom. |
||
128 | */ |
||
129 | public static function mergeUrlParams($urlToStealFrom, $urlToAddTo) |
||
139 | |||
140 | /** |
||
141 | * Check for a "/" prefix and prepend it if not exists. |
||
142 | * |
||
143 | * @param string|null $string |
||
144 | * |
||
145 | * @return string|null |
||
146 | */ |
||
147 | public static function forceSlashPrefix($string) |
||
155 | |||
156 | /** |
||
157 | * Trims off the hostname and Graph version from a URL. |
||
158 | * |
||
159 | * @param string $urlToTrim The URL the needs the surgery. |
||
160 | * |
||
161 | * @return string The $urlToTrim with the hostname and Graph version removed. |
||
162 | */ |
||
163 | public static function baseGraphUrlEndpoint($urlToTrim) |
||
167 | } |
||
168 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: