Conditions | 3 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 3 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
26 | 15 | public function __construct(array $routes) |
|
27 | { |
||
28 | 15 | $this->routes = array(); |
|
29 | |||
30 | 13 | $this->dispatcher = FastRoute\simpleDispatcher(function (RouteCollector $collector) use ($routes) { |
|
31 | 5 | foreach ($routes as $route) { |
|
32 | 12 | if (!$route instanceof RouteInterface) { |
|
33 | 1 | throw new \InvalidArgumentException('Routes array must contain only RouteInterface objects'); |
|
34 | } |
||
35 | |||
36 | 3 | $key = spl_object_hash($route); |
|
37 | |||
38 | 9 | $this->routes[$key] = $route; |
|
39 | |||
40 | 3 | $collector->addRoute($route->getMethods(), $route->getPattern(), $key); |
|
41 | 4 | } |
|
42 | 5 | }); |
|
43 | 6 | } |
|
44 | |||
62 |