Total Complexity | 7 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class RouterCollector implements RouterCollectorInterface, IndexCollectorInterface |
||
11 | { |
||
12 | use CollectorTrait; |
||
13 | |||
14 | private ContainerInterface $container; |
||
15 | private float $matchTime = 0; |
||
16 | |||
17 | 1 | public function __construct(ContainerInterface $container) |
|
20 | 1 | } |
|
21 | |||
22 | 1 | public function collect(float $matchTime): void |
|
23 | { |
||
24 | 1 | if (!$this->isActive()) { |
|
25 | return; |
||
26 | } |
||
27 | 1 | $this->matchTime = $matchTime; |
|
28 | 1 | } |
|
29 | |||
30 | 1 | public function getCollected(): array |
|
31 | { |
||
32 | 1 | $routeCollection = $this->container->has(RouteCollectionInterface::class) |
|
33 | 1 | ? $this->container->get(RouteCollectionInterface::class) |
|
34 | : null; |
||
35 | |||
36 | 1 | return $routeCollection === null ? [] : |
|
37 | [ |
||
38 | 1 | 'routesTree' => $routeCollection->getRouteTree(), |
|
39 | 1 | 'routes' => $routeCollection->getRoutes(), |
|
40 | 1 | 'routeTime' => $this->matchTime, |
|
41 | ]; |
||
42 | } |
||
43 | |||
44 | 1 | public function getIndexData(): array |
|
48 | ]; |
||
49 | } |
||
50 | } |
||
51 |