com\setasign\SetaFramework\Router\Route

Regex Class Route Regex

File: /SetaFramework/src/Router/Route/Regex.php

Class hierarchy

Implements

Summary

Properties

$defaultValues

protected array<string, mixed> Regex::$defaultValues

$logger

protected ?\Psr\Log\LoggerInterface Regex::$logger

$map

protected array<string, int|string> Regex::$map

$regex

protected string Regex::$regex

$requestPathPrefix

protected ?string Regex::$requestPathPrefix

Methods

__construct()

public Regex::__construct (
string $regex,
array<string, mixed> $defaultValues = array ( ),
array<string, int|string> $map = array ( ),
?string $requestPathPrefix = null
)

Constructor

The regex route checks the path with a regular expression.

The regex will start after the requestPathPrefix ends (without a starting slash).

e.g.: prefix=/asdf/bcd ; path=/asdf/bcd/efg/kli ; path which will checked by regex=efg/kli

If the requestPathPrefix doesn't match the route will fail.

Parameters
$regex : string

Regular expression

$defaultValues : array<string, mixed>
 
$map : array<string, int|string>
 
$requestPathPrefix : ?string
 
Exceptions

Throws \InvalidArgumentException

mapData()

protected Regex::mapData (
string[] $matches
): array
Parameters
$matches : string[]
 

match()

public Regex::match (
\Psr\Http\Message\RequestInterface $request
): ?array

Checks whether this route matches to the request

Parameters
$request : \Psr\Http\Message\RequestInterface
 
Return Values

Returns associative array(without any numeric key) with values or NULL if the route not match

Exceptions

Throws \com\setasign\SetaFramework\Router\RouteException If $request is no SetaFramework\Request\Http

See

setDefaultValue()

public Regex::setDefaultValue (
string $key,
mixed $value
): void

Sets a key of the defaultValues array

Parameters
$key : string

The key shouldn't be a natural number

$value : mixed
 

setDefaultValues()

public Regex::setDefaultValues (
array<string, mixed> $defaultValues
): void

Overwrites the defaultValues array

Parameters
$defaultValues : array<string, mixed>

The keys of this array shouldn't be natural numbers

setLogger()

public Regex::setLogger (
\Psr\Log\LoggerInterface $logger
): void

Sets a logger instance on the object.

Parameters
$logger : \Psr\Log\LoggerInterface