PHP Class JBZoo\Utils\Url

显示文件 Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
addArg ( array $newParams, mixed $uri = null ) : string Add or remove query arguments to the URL.
build ( array $queryParams ) : string
buildAll ( mixed $url, mixed $parts = [], integer $flags = self::URL_REPLACE, array &$newUrl = [] ) : string Build a URL. The parts of the second URL will be merged into the first according to the flags argument.
create ( array $parts = [] ) : string
current ( boolean $addAuth = false ) : string Return the current URL.
delArg ( string | array $keys, boolean $uri = null ) : string Removes an item or list from the query string.
getAuth ( ) : null | string Get current auth info
isAbsolute ( $path ) : boolean Is absolute url
isHttps ( boolean $trustProxyHeaders = false ) : boolean Checks to see if the page is being server over SSL or not
parseLink ( string $text ) : string Turns all of the links in a string into HTML links.
path ( ) : string Return the current path
pathToRel ( $path ) : string Convert file path to relative URL
pathToUrl ( $path ) : string Convert file path to absolute URL
root ( boolean $addAuth = false ) : null | string Return current root URL

Protected Methods

Method Description
_linkifyCallback ( string $matches ) : string Callback for the preg_replace in the linkify() method.
_linkifyRegex ( string $text ) : mixed Callback for the preg_replace in the linkify() method.

Method Details

_linkifyCallback() protected static method

Part of the LinkifyURL Project
protected static _linkifyCallback ( string $matches ) : string
$matches string Matches from the preg_ function
return string

_linkifyRegex() protected static method

Part of the LinkifyURL Project
protected static _linkifyRegex ( string $text ) : mixed
$text string Matches from the preg_ function
return mixed

addArg() public static method

Add or remove query arguments to the URL.
public static addArg ( array $newParams, mixed $uri = null ) : string
$newParams array Either newkey or an associative array
$uri mixed URI or URL to append the queru/queries to.
return string

build() public static method

public static build ( array $queryParams ) : string
$queryParams array
return string

buildAll() public static method

Build a URL. The parts of the second URL will be merged into the first according to the flags argument.
See also: https://github.com/jakeasmith/http_build_url/
Author: Jake Smith ([email protected])
public static buildAll ( mixed $url, mixed $parts = [], integer $flags = self::URL_REPLACE, array &$newUrl = [] ) : string
$url mixed (part(s) of) an URL in form of a string or associative array like parse_url() returns
$parts mixed same as the first argument
$flags integer a bitmask of binary or'ed HTTP_URL constants; HTTP_URL_REPLACE is the default
$newUrl array if set, it will be filled with the parts of the composed url like parse_url() would return
return string

create() public static method

public static create ( array $parts = [] ) : string
$parts array
return string

current() public static method

Return the current URL.
public static current ( boolean $addAuth = false ) : string
$addAuth boolean
return string

delArg() public static method

Removes an item or list from the query string.
public static delArg ( string | array $keys, boolean $uri = null ) : string
$keys string | array Query key or keys to remove.
$uri boolean When false uses the $_SERVER value
return string

getAuth() public static method

Get current auth info
public static getAuth ( ) : null | string
return null | string

isAbsolute() public static method

Is absolute url
public static isAbsolute ( $path ) : boolean
$path
return boolean

isHttps() public static method

Checks to see if the page is being server over SSL or not
public static isHttps ( boolean $trustProxyHeaders = false ) : boolean
$trustProxyHeaders boolean
return boolean

path() public static method

Return the current path
public static path ( ) : string
return string

pathToRel() public static method

Convert file path to relative URL
public static pathToRel ( $path ) : string
$path
return string

pathToUrl() public static method

Convert file path to absolute URL
public static pathToUrl ( $path ) : string
$path
return string

root() public static method

Return current root URL
public static root ( boolean $addAuth = false ) : null | string
$addAuth boolean
return null | string