Add ensureQueryParameter method to Util\Strings

This commit is contained in:
Hypolite Petovan 2019-01-11 19:27:56 -05:00
parent 3020b9cb06
commit a20fa6a3a9

View file

@ -312,4 +312,20 @@ class Strings
{
return (strcasecmp(self::normaliseLink($a), self::normaliseLink($b)) === 0);
}
/**
* Ensures the provided URI has its query string punctuation in order.
*
* @param string $uri
* @return string
*/
public static function ensureQueryParameter($uri)
{
if (strpos($uri, '?') === false && ($pos = strpos($uri, '&')) !== false) {
$uri = substr($uri, 0, $pos) . '?' . substr($uri, $pos + 1);
}
return $uri;
}
}