class Builder implements IBuilder (View source)

Responsible for building the URL of pages.

Properties

protected string $path Path component of the url (e.g. /path/to/page.html).
protected string $anchor The anchor component of the url (e.g. "shoes", if the url is "/view/category#shoes").
protected string $protocol The used protocol of the url.
protected string $host The host of the url.
protected integer|null $port The port of the url.
protected array $params GET url parameters.

Methods

__construct(array $components)

Constructor for the url builder.

string
build(array $params = array())

Builds the final url and merges saved params with given via parameter.

string
getPortForBuild()

Get the final port for build.

array
getParams()

Get params.

string
getPath()

Get path.

string
getAnchor()

Get anchor.

string
getHost()

Get host.

string
getProtocol()

Get used protocol.

integer
getPort()

Get used port.

array
unmaskUrl(string $url, array $params)

Unmasks a URL and replaces masks with a parameter value.

Expectation
shouldReceive(string $name)

No description

Details

__construct(array $components)

Constructor for the url builder.

Parameters

array $components The url components.

Exceptions

UrlException When the path, host or protocol are missing.

string build(array $params = array())

Builds the final url and merges saved params with given via parameter.

Parameters

array $params Additional GET params.

Return Value

string

protected string getPortForBuild()

Get the final port for build.

Return Value

string

array getParams()

Get params.

Return Value

array

string getPath()

Get path.

Return Value

string

string getAnchor()

Get anchor.

Return Value

string

string getHost()

Get host.

Return Value

string

string getProtocol()

Get used protocol.

Return Value

string

integer getPort()

Get used port.

Return Value

integer

protected array unmaskUrl(string $url, array $params)

Unmasks a URL and replaces masks with a parameter value.

Parameters

string $url URL to be unmasked.
array $params Params holding values for masks.

Return Value

array Returns an array of 0 => unmasked url and 1 => parameters.

Exceptions

MissingParametersException Thrown if a mask was found in $url which does not exist in $params.

Expectation shouldReceive(string $name)

Parameters

string $name

Return Value

Expectation