1 | <?php |
||
25 | class GenericApi implements ApiInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | static $formats = [ |
||
|
|||
32 | 'json' => ['application/json', 'application/x-json'], |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * @var ClientInterface $client |
||
37 | */ |
||
38 | private $client; |
||
39 | /** |
||
40 | * @var string $uri |
||
41 | */ |
||
42 | private $uri; |
||
43 | /** |
||
44 | * @var PaginatorFactoryInterface $paginatorFactory |
||
45 | */ |
||
46 | private $paginatorFactory; |
||
47 | |||
48 | /** |
||
49 | * @var AdapterFactoryInterface $apiAdapterFactory |
||
50 | */ |
||
51 | private $apiAdapterFactory; |
||
52 | |||
53 | /** |
||
54 | * @var JsonDecode $jsonDecoder |
||
55 | */ |
||
56 | private $jsonDecoder; |
||
57 | |||
58 | /** |
||
59 | * @param ClientInterface $client |
||
60 | * @param string $uri |
||
61 | * @param null|AdapterFactoryInterface $apiAdapterFactory |
||
62 | * @param null|PaginatorFactoryInterface $paginatorFactory |
||
63 | * @param null|JsonDecode $jsonDecoder |
||
64 | */ |
||
65 | public function __construct( |
||
78 | |||
79 | /** |
||
80 | * @param string $uri |
||
81 | * @throws \InvalidArgumentException |
||
82 | */ |
||
83 | private function setUri($uri) |
||
93 | |||
94 | /** |
||
95 | * @param array $uriParameters |
||
96 | * @return string |
||
97 | */ |
||
98 | private function getUri(array $uriParameters = []) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function get($id, array $queryParameters = [], array $uriParameters = []) |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function getAll(array $queryParameters = [], array $uriParameters = []) |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function getPaginated(array $queryParameters = [], array $uriParameters = []) |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | public function createPaginator(array $queryParameters = [], array $uriParameters = []) |
||
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | public function create(array $body, array $uriParameters = [], array $files = []) |
||
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | public function update($id, array $body, array $uriParameters = [], array $files = []) |
||
181 | |||
182 | /** |
||
183 | * {@inheritdoc} |
||
184 | */ |
||
185 | public function put($id, array $body, array $uriParameters = []) |
||
192 | |||
193 | /** |
||
194 | * {@inheritdoc} |
||
195 | */ |
||
196 | public function delete($id, array $uriParameters = []) |
||
202 | |||
203 | private function responseToArray(ResponseInterface $response) |
||
209 | |||
210 | private function getResponseType(ResponseInterface $response) |
||
223 | |||
224 | /** |
||
225 | * @param $body |
||
226 | * @return mixed |
||
227 | */ |
||
228 | private function json($body) |
||
232 | } |
||
233 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.