1 | <?php |
||
20 | class Router { |
||
21 | /** |
||
22 | * @var AccessControl |
||
23 | */ |
||
24 | protected $accessControl; |
||
25 | /** |
||
26 | * @var Throttle |
||
27 | */ |
||
28 | protected $throttle; |
||
29 | /** |
||
30 | * @var Configuration |
||
31 | */ |
||
32 | protected $outputConfig; |
||
33 | /** |
||
34 | * @var Configuration |
||
35 | */ |
||
36 | protected $formatsConfig; |
||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $endpointNamespace; |
||
41 | |||
42 | /** |
||
43 | * @param AccessControl $accessControl |
||
44 | * @param Throttle $throttle |
||
45 | * @param Configuration $formatsConfig |
||
46 | * @param string $endpointNamespace |
||
47 | */ |
||
48 | public function __construct(AccessControl $accessControl, Throttle $throttle, Configuration $formatsConfig, $endpointNamespace = ''){ |
||
54 | |||
55 | /** |
||
56 | * @param Request $request |
||
57 | * @return string |
||
58 | * @throws AccessDeniedException |
||
59 | * @throws InvalidAPIKeyException |
||
60 | * @throws InvalidResponseFormatException |
||
61 | * @throws ThrottleLimitExceededException |
||
62 | * @throws UnknownEndpointException |
||
63 | * @throws UnknownResponseFormatException |
||
64 | */ |
||
65 | public function handle(Request $request){ |
||
87 | |||
88 | /** |
||
89 | * @param Request $request |
||
90 | * @return string |
||
91 | */ |
||
92 | private function endpointClass(Request $request){ |
||
95 | |||
96 | /** |
||
97 | * @param Request $request |
||
98 | * @return string |
||
99 | */ |
||
100 | private function responseClass(Request $request){ |
||
103 | |||
104 | /** |
||
105 | * @param Request $request |
||
106 | * @throws InvalidAPIKeyException |
||
107 | */ |
||
108 | private function validateKey(Request $request){ |
||
113 | |||
114 | /** |
||
115 | * @param Request $request |
||
116 | * @return bool |
||
117 | * @throws UnknownResponseFormatException |
||
118 | */ |
||
119 | private function validateExtension(Request $request) |
||
126 | |||
127 | /** |
||
128 | * @param $fullEndpoint |
||
129 | * @throws UnknownEndpointException |
||
130 | */ |
||
131 | private function validateEndpoint($fullEndpoint){ |
||
137 | |||
138 | /** |
||
139 | * @param Request $request |
||
140 | * @throws ThrottleLimitExceededException |
||
141 | */ |
||
142 | private function throttle(Request $request){ |
||
147 | |||
148 | /** |
||
149 | * @param Request $request |
||
150 | * @throws AccessDeniedException |
||
151 | */ |
||
152 | private function validateAccess(Request $request){ |
||
157 | |||
158 | /** |
||
159 | * @param $responseData |
||
160 | * @throws InvalidResponseFormatException |
||
161 | */ |
||
162 | private function validateResponse($responseData){ |
||
167 | |||
168 | private function executeEndpoint($fullEndpoint, Request $request){ |
||
172 | |||
173 | /** |
||
174 | * @param AccessControl $accessControl |
||
175 | */ |
||
176 | public function setAccessControl(AccessControl $accessControl) |
||
180 | |||
181 | /** |
||
182 | * @param Throttle $throttle |
||
183 | */ |
||
184 | public function setThrottle(Throttle $throttle) |
||
188 | |||
189 | /** |
||
190 | * @param Configuration $formatsConfig |
||
191 | */ |
||
192 | public function setFormatsConfig(Configuration $formatsConfig) |
||
196 | |||
197 | /** |
||
198 | * @param string $endpointNamespace |
||
199 | */ |
||
200 | public function setEndpointNamespace($endpointNamespace) |
||
204 | } |
||
205 |