1 | <?php |
||
22 | class Router { |
||
23 | /** |
||
24 | * @var AccessControl |
||
25 | */ |
||
26 | protected $accessControl; |
||
27 | /** |
||
28 | * @var Throttle |
||
29 | */ |
||
30 | protected $throttle; |
||
31 | /** |
||
32 | * @var ResponseFactory |
||
33 | */ |
||
34 | protected $responseFactory; |
||
35 | /** |
||
36 | * @var EndpointFactory |
||
37 | */ |
||
38 | private $endpointFactory; |
||
39 | |||
40 | /** |
||
41 | * @param AccessControl $accessControl |
||
42 | * @param Throttle $throttle |
||
43 | * @param ResponseFactory $responseFactory |
||
44 | * @param EndpointFactory $endpointFactory |
||
45 | */ |
||
46 | public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory){ |
||
52 | |||
53 | /** |
||
54 | * @param Request $request |
||
55 | * @return Response |
||
56 | * @throws AccessDeniedException |
||
57 | * @throws InvalidAPIKeyException |
||
58 | * @throws ThrottleLimitExceededException |
||
59 | * @throws UnknownEndpointException |
||
60 | * @throws UnknownResponseTypeException |
||
61 | */ |
||
62 | public function route(Request $request): Response{ |
||
83 | |||
84 | /** |
||
85 | * @param Request $request |
||
86 | * @throws InvalidAPIKeyException |
||
87 | */ |
||
88 | protected function validateKey(Request $request){ |
||
93 | |||
94 | /** |
||
95 | * @param Request $request |
||
96 | * @throws UnknownResponseTypeException |
||
97 | */ |
||
98 | protected function validateExtension(Request $request) { |
||
104 | |||
105 | /** |
||
106 | * @param Request $request |
||
107 | * @throws ThrottleLimitExceededException |
||
108 | */ |
||
109 | protected function throttle(Request $request) { |
||
111 | |||
112 | /** |
||
113 | * @param Request $request |
||
114 | * @throws AccessDeniedException |
||
115 | */ |
||
116 | protected function validateAccess(Request $request) { |
||
118 | |||
119 | protected function executeEndpoint(Endpoint $endpoint, Request $request): ResponseData { |
||
122 | } |
||
123 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.