1 | <?php |
||
22 | abstract class ResourceAbstract implements ResourceInterface |
||
|
|||
23 | { |
||
24 | const ASSERT_TYPE_NULL = 'null'; |
||
25 | const ASSERT_TYPE_STRING = 'string'; |
||
26 | const ASSERT_TYPE_ARRAY = 'array'; |
||
27 | |||
28 | /** |
||
29 | * @var ConfigInterface |
||
30 | */ |
||
31 | protected $config; |
||
32 | |||
33 | /** |
||
34 | * @param ConfigInterface $config |
||
35 | */ |
||
36 | 66 | public function __construct(ConfigInterface $config) |
|
40 | |||
41 | /** |
||
42 | * @return string |
||
43 | */ |
||
44 | abstract protected function getResponseClass(); |
||
45 | |||
46 | /** |
||
47 | * @return array |
||
48 | */ |
||
49 | abstract protected function getResourceMethodConfiguration(); |
||
50 | |||
51 | /** |
||
52 | * @return ConfigInterface |
||
53 | */ |
||
54 | 55 | protected function getConfig() |
|
58 | |||
59 | /** |
||
60 | * @param ConfigInterface $config |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | 66 | protected function setConfig(ConfigInterface $config) |
|
65 | { |
||
66 | 66 | $this->config = $config; |
|
67 | |||
68 | 66 | return $this; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * @param string $requestMethod |
||
73 | * @param string $resourceMethod |
||
74 | * @param array $params |
||
75 | * @param string|array|null $id |
||
76 | * |
||
77 | * @return mixed |
||
78 | * @throws \LogicException |
||
79 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
80 | * @throws \Exception |
||
81 | * @throws \InvalidArgumentException |
||
82 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ApiException |
||
83 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\AccessForbiddenException |
||
84 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\InvalidParameterException |
||
85 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\InvalidRequestException |
||
86 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\NotAllowedException |
||
87 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\NotAuthorizedException |
||
88 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ParameterRequiredException |
||
89 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ResourceNotFoundException |
||
90 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ServerErrorException |
||
91 | */ |
||
92 | 55 | protected function request($requestMethod, $resourceMethod, array $params, $id) |
|
103 | |||
104 | /** |
||
105 | * @param string $requestMethod |
||
106 | * @param string $path |
||
107 | * @param array $options |
||
108 | * @param string $responseDocumentClass |
||
109 | * |
||
110 | * @return mixed |
||
111 | * @throws \LogicException |
||
112 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
113 | * @throws \Exception |
||
114 | * @throws \InvalidArgumentException |
||
115 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ApiException |
||
116 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\AccessForbiddenException |
||
117 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\InvalidParameterException |
||
118 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\InvalidRequestException |
||
119 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\NotAllowedException |
||
120 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\NotAuthorizedException |
||
121 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ParameterRequiredException |
||
122 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ResourceNotFoundException |
||
123 | * @throws \Zibios\WrikePhpSdk\Exceptions\Api\ServerErrorException |
||
124 | */ |
||
125 | 55 | private function executeRequest($requestMethod, $path, array $options, $responseDocumentClass) |
|
171 | |||
172 | /** |
||
173 | * @param mixed $value |
||
174 | * @param string $type |
||
175 | * |
||
176 | * @throws \InvalidArgumentException |
||
177 | */ |
||
178 | 55 | private function assertIsValidId($value, $type) |
|
204 | |||
205 | /** |
||
206 | * @param string $resourceMethod |
||
207 | * @param string|array|null $id |
||
208 | * |
||
209 | * @return string |
||
210 | * @throws \InvalidArgumentException |
||
211 | */ |
||
212 | 55 | private function prepareRequestPathForResourceMethod($resourceMethod, $id) |
|
238 | |||
239 | /** |
||
240 | * @param string $requestMethod |
||
241 | * @param array $params |
||
242 | * |
||
243 | * @return array |
||
244 | * @throws \InvalidArgumentException |
||
245 | */ |
||
246 | 55 | protected function prepareRequestOptionsForRequestMethod($requestMethod, array $params) |
|
272 | } |
||
273 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.