| Total Complexity | 7 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | trait Matcher |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Set param |
||
| 11 | * |
||
| 12 | * @param string $routeUrl |
||
| 13 | * @return string |
||
| 14 | */ |
||
| 15 | protected function setParam(string $routeUrl): string |
||
| 16 | { |
||
| 17 | $routeUrl = explode('/', $routeUrl); |
||
| 18 | |||
| 19 | foreach ($routeUrl as $k => $v) { |
||
| 20 | if (preg_match('/^\{.*\}$/', $v) && (count($this->url) == count($routeUrl))) { |
||
| 21 | $routeUrl[$k] = $this->url[$k]; |
||
| 22 | $this->param = $this->url[$k]; |
||
|
|
|||
| 23 | } |
||
| 24 | |||
| 25 | $route = implode('/', $routeUrl); |
||
| 26 | } |
||
| 27 | |||
| 28 | return $route; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Find the corresponding route based on the given URL |
||
| 33 | * |
||
| 34 | * @param array $url |
||
| 35 | * @return Router|null |
||
| 36 | */ |
||
| 37 | protected function match(array $url): ?Router |
||
| 50 | } |
||
| 51 | } |
||
| 52 |