PHP Класс Piwik\UrlHelper

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
getArrayFromQueryString ( string $urlQuery ) : array Returns a URL query string as an array.
getHostFromUrl ( $url )
getLossyUrl ( string $url ) : string Reduce URL to more minimal form. 2 letter country codes are replaced by '{}', while other parts are simply removed.
getParameterFromQueryString ( string $urlQuery, string $parameter ) : string | null Returns the value of a single query parameter from the supplied query string.
getParseUrlReverse ( array $parsed ) : false | string Returns a URL created from the result of the parse_url function.
getPathAndQueryFromUrl ( string $url ) : string Returns the path and query string of a URL.
getQueryFromUrl ( string $url, array $additionalParamsToAdd = [] ) : string Returns the query part from any valid url and adds additional parameters to the query part if needed.
getQueryStringWithExcludedParameters ( $queryParameters, $parametersToExclude ) : string Converts an array of query parameter name/value mappings into a query string.
isLookLikeUrl ( string $url ) : boolean Returns true if the string passed may be a URL ie. it starts with protocol://.

Защищенные методы

Метод Описание
in_array_matches_regex ( $test, $patterns ) : true Checks if a string matches/is equal to one of the patterns/strings.

Описание методов

getArrayFromQueryString() публичный статический Метод

Returns a URL query string as an array.
public static getArrayFromQueryString ( string $urlQuery ) : array
$urlQuery string The query string, eg, `'?param1=value1¶m2=value2'`.
Результат array eg, `array('param1' => 'value1', 'param2' => 'value2')`

getHostFromUrl() публичный статический Метод

public static getHostFromUrl ( $url )

getLossyUrl() публичный статический Метод

Examples: www.example.com -> example.com search.example.com -> example.com m.example.com -> example.com de.example.com -> }.example.com example.de -> example.} example.co.uk -> example.}
public static getLossyUrl ( string $url ) : string
$url string
Результат string

getParameterFromQueryString() публичный статический Метод

Returns the value of a single query parameter from the supplied query string.
public static getParameterFromQueryString ( string $urlQuery, string $parameter ) : string | null
$urlQuery string The query string.
$parameter string The query parameter name to return.
Результат string | null Parameter value if found (can be the empty string!), null if not found.

getParseUrlReverse() публичный статический Метод

Copied from the PHP comments at http://php.net/parse_url.
public static getParseUrlReverse ( array $parsed ) : false | string
$parsed array Result of [parse_url](http://php.net/manual/en/function.parse-url.php).
Результат false | string The URL or `false` if `$parsed` isn't an array.

getPathAndQueryFromUrl() публичный статический Метод

Returns the path and query string of a URL.
public static getPathAndQueryFromUrl ( string $url ) : string
$url string The URL.
Результат string eg, `/test/index.php?module=CoreHome` if `$url` is `http://piwik.org/test/index.php?module=CoreHome`.

getQueryFromUrl() публичный статический Метод

Returns the query part from any valid url and adds additional parameters to the query part if needed.
public static getQueryFromUrl ( string $url, array $additionalParamsToAdd = [] ) : string
$url string Any url eg `"http://example.com/piwik/?foo=bar"`
$additionalParamsToAdd array If not empty the given parameters will be added to the query.
Результат string eg. `"foo=bar&foo2=bar2"`

getQueryStringWithExcludedParameters() публичный статический Метод

Parameters that are in $parametersToExclude will not appear in the result.
public static getQueryStringWithExcludedParameters ( $queryParameters, $parametersToExclude ) : string
$queryParameters Array of query parameters, eg, `array('site' => '0', 'date' => '2012-01-01')`.
$parametersToExclude Array of query parameter names that shouldn't be in the result query string, eg, `array('date', 'period')`.
Результат string A query string, eg, `"?site=0"`.

in_array_matches_regex() защищенный статический Метод

Checks if a string matches/is equal to one of the patterns/strings.
protected static in_array_matches_regex ( $test, $patterns ) : true
$test String to test.
$patterns Array of strings or regexs.
Результат true if $test matches or is equal to one of the regex/string in $patterns, false otherwise.

isLookLikeUrl() публичный статический Метод

We don't need a precise test here because the value comes from the website tracked source code and the URLs may look very strange.
public static isLookLikeUrl ( string $url ) : boolean
$url string
Результат boolean