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
public static
is_pattern( string $pattern
)
: boolean
Checks if the given string is a route pattern.
public static
from( mixed $pattern
)
: ICanBoogie\Routing\Pattern
Creates a ICanBoogie\Routing\Pattern
instance from the specified pattern.