| Total Complexity | 6 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | class RouteRegex implements RouteStrategyInterface |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Variable contains array of named sub-patterns values |
||
| 26 | * |
||
| 27 | * @var array|null |
||
| 28 | */ |
||
| 29 | protected static $params; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Check if given url matches route pattern |
||
| 33 | * |
||
| 34 | * @param string $pattern Pattern from route config |
||
| 35 | * @param string $url current $_SERVER['REQUEST_URI'] without params |
||
| 36 | * |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | 16 | public static function check($pattern, $url) |
|
| 40 | { |
||
| 41 | 16 | self::$params = null; |
|
| 42 | |||
| 43 | 16 | if (1 === ($result = preg_match($pattern, $url, $matches))) { |
|
| 44 | 13 | self::unsetNumericKeys($matches); |
|
| 45 | |||
| 46 | 13 | self::$params = $matches; |
|
| 47 | } |
||
| 48 | |||
| 49 | 16 | return (bool) $result; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get url maps |
||
| 54 | * |
||
| 55 | * @return mixed |
||
| 56 | */ |
||
| 57 | 11 | public static function getParams() |
|
| 60 | } |
||
| 61 | |||
| 62 | 13 | protected static function unsetNumericKeys(&$matches) |
|
| 67 | } |
||
| 68 | } |
||
| 71 |