PHP Class Purl\Url

Author: Jonathan H. Wage ([email protected])
Inheritance: extends purl\AbstractPart
Show file Open project: jwage/purl Class Usage Examples

Protected Properties

Property Type Description
$data array
$partClassMap array

Public Methods

Method Description
__construct ( string $url = null, purl\ParserInterface $parser = null ) Construct a new Url instance.
__toString ( )
extract ( string $string ) : array Extracts urls from a string of text.
fromCurrent ( ) : Url Creates an Url instance based on data available on $_SERVER variable.
getFragment ( ) : purl\Fragment Get the Fragment instance.
getNetloc ( ) : string Gets the netloc part of the Url. It is the user, pass, host and port returned as a string.
getParser ( ) : purl\ParserInterface Gets the ParserInterface instance used to parse this Url instance.
getPath ( ) : purl\Path Get the Path instance.
getQuery ( ) : Query Get the Query instance.
getUrl ( ) : string Builds a string url from this Url instance internal data and returns it.
isAbsolute ( ) : boolean Checks if the Url instance is absolute or not.
join ( Url | string $url ) : Url Join this Url instance together with another Url instance or a string url.
parse ( string $url ) : Url Static convenience method for creating a new Url instance.
set ( $key, $value )
setFragment ( purl\Fragment $fragment ) Set the Fragment instance.
setParser ( purl\ParserInterface $parser ) Sets the ParserInterface instance to use to parse this Url instance.
setPath ( purl\Path $path ) Set the Path instance.
setQuery ( Query $query ) Set the Query instance.
setUrl ( $url ) Set the string url for this Url instance and sets initialized to false.

Protected Methods

Method Description
doInitialize ( )

Private Methods

Method Description
createDefaultParser ( ) : Parser Creates the default Parser instance to parse urls.
httpBuildRelativeUrl ( array $parts ) : string Reconstructs relative part of URL from an array of parts.
httpBuildUrl ( array $parts ) : string Reconstructs a string URL from an array of parts.

Method Details

__construct() public method

Construct a new Url instance.
public __construct ( string $url = null, purl\ParserInterface $parser = null )
$url string
$parser purl\ParserInterface

__toString() public method

public __toString ( )

doInitialize() protected method

protected doInitialize ( )

extract() public static method

Extracts urls from a string of text.
public static extract ( string $string ) : array
$string string
return array $urls

fromCurrent() public static method

Creates an Url instance based on data available on $_SERVER variable.
public static fromCurrent ( ) : Url
return Url

getFragment() public method

Get the Fragment instance.
public getFragment ( ) : purl\Fragment
return purl\Fragment

getNetloc() public method

Gets the netloc part of the Url. It is the user, pass, host and port returned as a string.
public getNetloc ( ) : string
return string

getParser() public method

Gets the ParserInterface instance used to parse this Url instance.
public getParser ( ) : purl\ParserInterface
return purl\ParserInterface

getPath() public method

Get the Path instance.
public getPath ( ) : purl\Path
return purl\Path

getQuery() public method

Get the Query instance.
public getQuery ( ) : Query
return Query

getUrl() public method

Builds a string url from this Url instance internal data and returns it.
public getUrl ( ) : string
return string

isAbsolute() public method

Checks if the Url instance is absolute or not.
public isAbsolute ( ) : boolean
return boolean

join() public method

Join this Url instance together with another Url instance or a string url.
public join ( Url | string $url ) : Url
$url Url | string
return Url

parse() public static method

Static convenience method for creating a new Url instance.
public static parse ( string $url ) : Url
$url string
return Url

set() public method

public set ( $key, $value )

setFragment() public method

Set the Fragment instance.
public setFragment ( purl\Fragment $fragment )
$fragment purl\Fragment

setParser() public method

Sets the ParserInterface instance to use to parse this Url instance.
public setParser ( purl\ParserInterface $parser )
$parser purl\ParserInterface

setPath() public method

Set the Path instance.
public setPath ( purl\Path $path )
$path purl\Path

setQuery() public method

Set the Query instance.
public setQuery ( Query $query )
$query Query

setUrl() public method

Set the string url for this Url instance and sets initialized to false.
public setUrl ( $url )

Property Details

$data protected property

protected array $data
return array

$partClassMap protected property

protected array $partClassMap
return array