Total Complexity | 7 |
Total Lines | 102 |
Duplicated Lines | 0 % |
Coverage | 87.1% |
Changes | 0 |
1 | <?php |
||
9 | class Router implements IRouter |
||
10 | { |
||
11 | /** |
||
12 | * active route |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $activeRoute; |
||
17 | |||
18 | /** |
||
19 | * routes collection |
||
20 | * |
||
21 | * @var IRoutes |
||
22 | */ |
||
23 | private $routes; |
||
24 | |||
25 | /** |
||
26 | * request |
||
27 | * |
||
28 | * @var IRequest |
||
29 | */ |
||
30 | private $request = null; |
||
31 | |||
32 | /** |
||
33 | * route params |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $params; |
||
38 | |||
39 | /** |
||
40 | * route match expr |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | private $matchingRoute; |
||
45 | |||
46 | /** |
||
47 | * instanciate |
||
48 | * |
||
49 | * @param IRoutes $routes |
||
50 | * @param IRequest $request |
||
51 | */ |
||
52 | 3 | public function __construct(IRoutes $routes, IRequest $request) |
|
53 | { |
||
54 | 3 | $this->routes = []; |
|
|
|||
55 | 3 | $this->request = $request; |
|
56 | 3 | $this->activeRoute = ''; |
|
57 | 3 | $this->params = []; |
|
58 | 3 | $this->matchingRoute = ''; |
|
59 | 3 | $this->setRoutes($routes); |
|
60 | 3 | $this->activeRoute = substr($this->request->getUri(), 1); |
|
61 | 3 | return $this; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * set routes |
||
66 | * |
||
67 | * @param IRoutes $routes |
||
68 | * @return Router |
||
69 | */ |
||
70 | 3 | public function setRoutes(IRoutes $routes): Router |
|
71 | { |
||
72 | 3 | $this->routes = $routes->get(); |
|
73 | 3 | return $this; |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * compile |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | 1 | public function compile(): array |
|
101 | } |
||
102 | |||
103 | public function getParams():array |
||
106 | } |
||
107 | |||
108 | public function getMatchingRoute():string |
||
113 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..