Class Pattern
Representation of a route pattern.
<?php use ICanBoogie\Routing\Pattern; $pattern = Pattern::from("/blog/<year:\d{4}>-<month:\d{2}>-:slug.html"); echo $pattern; // "/blog/<year:\d{4}>-<month:\d{2}>-:slug.html" $pathname = $pattern->format([ 'year' => "2013", 'month' => "07", 'slug' => "test-is-a-test" ]); echo $pathname; // "/blog/2013-07-this-is-a-test.html" $matching = $pattern->match($pathname, $captured); var_dump($matching); // true var_dump($captured); // [ 'year' => "2013", 'month' => "07", 'slug' => "test-is-a-test" ]
- ICanBoogie\Routing\Pattern uses ICanBoogie\Accessor\AccessorTrait (not available)
Methods summary
protected static
mixed
|
|
protected static
mixed
|
|
public static
boolean
|
|
public static
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
#
__construct( string $pattern )
Initializes the $pattern, $interleaved, $params and $regex properties. |
public
string
|
|
public
string
|
|
public
boolean
|
Properties summary
protected static
array
|
$extended_character_classes
|
#
[
'{:uuid:}' => '[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}',
'{:sha1:}' => '[a-f0-9]{40}'
]
|
Magic properties
public read-only
string
|
$pattern
The pattern. |
public read-only
array
|
$interleaved
The interleaved parts of the pattern. |
public read-only
array
|
$params
The names of the pattern params. |
public read-only
string
|
$regex
The regex of the pattern. |