1 | <?php |
||
24 | abstract class AbstractResource implements ResourceInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var ClientInterface |
||
28 | */ |
||
29 | protected $client; |
||
30 | |||
31 | /** |
||
32 | * @var ResponseTransformerInterface |
||
33 | */ |
||
34 | protected $responseTransformer; |
||
35 | |||
36 | /** |
||
37 | * @param ClientInterface $client |
||
38 | * @param ResponseTransformerInterface $responseTransformer |
||
39 | */ |
||
40 | 200 | public function __construct( |
|
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | abstract protected function getResourceMethodConfiguration(); |
||
52 | |||
53 | /** |
||
54 | * @param string $requestMethod |
||
55 | * @param string $resourceMethod |
||
56 | * @param array $params |
||
57 | * @param string|array|null $id |
||
58 | * |
||
59 | * @throws \RuntimeException |
||
60 | * @throws \LogicException |
||
61 | * @throws \Exception |
||
62 | * @throws \InvalidArgumentException |
||
63 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ApiException |
||
64 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\AccessForbiddenException |
||
65 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidParameterException |
||
66 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidRequestException |
||
67 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAllowedException |
||
68 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAuthorizedException |
||
69 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ParameterRequiredException |
||
70 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ResourceNotFoundException |
||
71 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ServerErrorException |
||
72 | * |
||
73 | * @return mixed |
||
74 | */ |
||
75 | 168 | protected function executeRequest($requestMethod, $resourceMethod, array $params, $id) |
|
93 | |||
94 | /** |
||
95 | * @param string $resourceMethod |
||
96 | * @param string|array|null $id |
||
97 | * |
||
98 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
||
99 | * |
||
100 | * @throws \InvalidArgumentException |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 168 | private function prepareRequestPathForResourceMethod($resourceMethod, $id) |
|
143 | |||
144 | /** |
||
145 | * @param string $resourceMethod |
||
146 | * |
||
147 | * @throws \InvalidArgumentException |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 168 | private function calculateRequestPathFormat($resourceMethod) |
|
160 | |||
161 | /** |
||
162 | * @param mixed $value |
||
163 | * |
||
164 | * @throws \InvalidArgumentException |
||
165 | */ |
||
166 | 20 | private function assertIsNull($value) |
|
172 | |||
173 | /** |
||
174 | * @param mixed $value |
||
175 | * |
||
176 | * @throws \InvalidArgumentException |
||
177 | */ |
||
178 | 148 | private function assertIsValidIdString($value) |
|
184 | |||
185 | /** |
||
186 | * @param mixed $value |
||
187 | * |
||
188 | * @throws \InvalidArgumentException |
||
189 | */ |
||
190 | 12 | private function assertIsValidIdArray($value) |
|
201 | } |
||
202 |