1 | <?php |
||
22 | class GenericRouter implements Router |
||
23 | { |
||
24 | /** |
||
25 | * @var EndpointFactory |
||
26 | */ |
||
27 | private $endpointFactory; |
||
28 | |||
29 | /** |
||
30 | * DefaultRouter constructor. |
||
31 | * @param EndpointFactory $endpointFactory |
||
32 | */ |
||
33 | 3 | public function __construct(EndpointFactory $endpointFactory) |
|
37 | |||
38 | /** |
||
39 | * @param APIRequest $request |
||
40 | * @return APIResponseData |
||
41 | * @throws UnableToRouteRequestException |
||
42 | * @throws UnableToCreateEndpointException |
||
43 | * @throws MethodNotFoundException |
||
44 | * @throws EndpointExecutionException |
||
45 | * @throws UnsupportedMethodException |
||
46 | * @throws ElementNotFoundException |
||
47 | * @throws InvalidRequestException |
||
48 | * @throws ElementConflictException |
||
49 | */ |
||
50 | 3 | public function route(APIRequest $request): APIResponseData |
|
55 | |||
56 | /** |
||
57 | * @param Endpoint $endpoint |
||
58 | * @param APIRequest $request |
||
59 | * @return APIResponseData |
||
60 | * @throws UnableToRouteRequestException |
||
61 | * @throws MethodNotFoundException |
||
62 | * @throws EndpointExecutionException |
||
63 | * @throws UnsupportedMethodException |
||
64 | * @throws ElementNotFoundException |
||
65 | * @throws InvalidRequestException |
||
66 | * @throws ElementConflictException |
||
67 | */ |
||
68 | 3 | protected function executeEndpoint(Endpoint $endpoint, APIRequest $request): APIResponseData |
|
76 | |||
77 | /** |
||
78 | * @param APIRequest $request |
||
79 | * @return string |
||
80 | */ |
||
81 | 3 | protected function mapEndpointMethod(APIRequest $request): string |
|
85 | } |
||
86 |