| Conditions | 3 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 55 | 10 | public function compileRegex() |
|
| 56 | { |
||
| 57 | 10 | $route = $this->route->getUri(); |
|
| 58 | |||
| 59 | 10 | if (strpos($route, '?')) { |
|
| 60 | 1 | $route = preg_replace('@\/{([\w]+)\?}@', '(?:/{$1})?', $route); |
|
| 61 | } |
||
| 62 | |||
| 63 | 10 | $route = preg_replace('/{([a-z0-9_-]+)}/i', '(?P<$1>[^/]+)', $route); |
|
| 64 | |||
| 65 | 10 | if(substr($route, -1) === '/') { |
|
| 66 | 5 | $route .= '?'; |
|
| 67 | } |
||
| 68 | |||
| 69 | 10 | return "%^{$route}$%s"; |
|
| 70 | } |
||
| 72 |