Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | public function make(string $name, array $parameters = []): string |
||
29 | { |
||
30 | if (!($route = $this->repository->findByName($name))) { |
||
31 | throw new UndefinedRouteException("There is no route named `$name`."); |
||
32 | } |
||
33 | |||
34 | $uri = $route->getPath(); |
||
35 | |||
36 | foreach ($parameters as $key => $value) { |
||
37 | $uri = preg_replace('/\??{' . $key . '\??}/', $value, $uri); |
||
38 | } |
||
39 | |||
40 | $uri = preg_replace('/{[^}]+\?}/', '', $uri); |
||
41 | return str_replace('/?', '', $uri); |
||
42 | } |
||
44 |