class RouterHelper

Methods that may be useful for processing routing activity

Methods

static string
normalizeUrl(string $url)

Adds leading slash and removes trailing slash from the URL.

static array
segmentizeUrl(string $url)

Splits an URL by segments separated by the slash symbol.

static string
rebuildUrl(array $urlArray)

Rebuilds a URL from an array of segments.

static string
parseValues(stdClass|array $object, array $columns, string $string)

Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe

static bool
segmentIsWildcard(string $segment)

Checks whether an URL pattern segment is a wildcard.

static bool
segmentIsOptional(string $segment)

Checks whether an URL pattern segment is optional.

static string
getParameterName(string $segment)

Extracts the parameter name from a URL pattern segment definition.

static string
getSegmentRegExp(string $segment)

Extracts the regular expression from a URL pattern segment definition.

static string
getSegmentDefaultValue(string $segment)

Extracts the default parameter value from a URL pattern segment definition.

Details

at line 20
static string normalizeUrl(string $url)

Adds leading slash and removes trailing slash from the URL.

Parameters

string $url

URL to normalize

Return Value

string

returns normalized URL

at line 42
static array segmentizeUrl(string $url)

Splits an URL by segments separated by the slash symbol.

Parameters

string $url

URL to segmentize

Return Value

array

returns the URL segments

at line 62
static string rebuildUrl(array $urlArray)

Rebuilds a URL from an array of segments.

Parameters

array $urlArray

array the URL segments

Return Value

string

returns rebuilt URL

at line 81
static string parseValues(stdClass|array $object, array $columns, string $string)

Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe

Parameters

stdClass|array $object

Object containing the data

array $columns

Expected key names to parse

string $string

URL template

Return Value

string

Built string

at line 107
static bool segmentIsWildcard(string $segment)

Checks whether an URL pattern segment is a wildcard.

Parameters

string $segment

the segment definition

Return Value

bool

Returns boolean true if the segment is a wildcard. Returns false otherwise.

at line 117
static bool segmentIsOptional(string $segment)

Checks whether an URL pattern segment is optional.

Parameters

string $segment

the segment definition

Return Value

bool

Returns boolean true if the segment is optional. Returns false otherwise.

at line 143
static string getParameterName(string $segment)

Extracts the parameter name from a URL pattern segment definition.

Parameters

string $segment

the segment definition

Return Value

string

returns the segment name

at line 179
static string getSegmentRegExp(string $segment)

Extracts the regular expression from a URL pattern segment definition.

Parameters

string $segment

the segment definition

Return Value

string

returns the regular expression string or false if the expression is not defined

at line 198
static string getSegmentDefaultValue(string $segment)

Extracts the default parameter value from a URL pattern segment definition.

Parameters

string $segment

the segment definition

Return Value

string

Returns the default value if it is provided. Returns false otherwise.