1 | <?php namespace JobApis\Jobs\Client\Providers; |
||
8 | abstract class AbstractProvider |
||
9 | { |
||
10 | /** |
||
11 | * HTTP Client |
||
12 | * |
||
13 | * @var HttpClient |
||
14 | */ |
||
15 | protected $client; |
||
16 | |||
17 | /** |
||
18 | * Query params |
||
19 | * |
||
20 | * @var AbstractQuery |
||
21 | */ |
||
22 | protected $query; |
||
23 | |||
24 | /** |
||
25 | * Create new client |
||
26 | * |
||
27 | * @param array $parameters |
||
|
|||
28 | */ |
||
29 | 16 | public function __construct(AbstractQuery $query) |
|
34 | |||
35 | /** |
||
36 | * Returns the standardized job object |
||
37 | * |
||
38 | * @param array|object $payload |
||
39 | * |
||
40 | * @return \JobApis\Jobs\Client\Job |
||
41 | */ |
||
42 | abstract public function createJobObject($payload); |
||
43 | |||
44 | /** |
||
45 | * Job response object default keys that should be set |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | abstract public function getDefaultResponseFields(); |
||
50 | |||
51 | /** |
||
52 | * Get listings path |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | abstract public function getListingsPath(); |
||
57 | |||
58 | /** |
||
59 | * Uses the Query to make a call to the client |
||
60 | * |
||
61 | * @return \Psr\Http\Message\ResponseInterface |
||
62 | */ |
||
63 | 6 | public function getClientResponse() |
|
80 | |||
81 | /** |
||
82 | * Get format |
||
83 | * |
||
84 | * @return string Currently only 'json' and 'xml' supported |
||
85 | */ |
||
86 | 6 | public function getFormat() |
|
90 | |||
91 | /** |
||
92 | * Makes the api call and returns a collection of job objects |
||
93 | * |
||
94 | * @return \JobApis\Jobs\Client\Collection |
||
95 | * @throws MissingParameterException |
||
96 | */ |
||
97 | 6 | public function getJobs() |
|
115 | |||
116 | /** |
||
117 | * Get source attribution |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 6 | public function getSource() |
|
127 | |||
128 | /** |
||
129 | * Parse job attributes against defaults |
||
130 | * |
||
131 | * @param array $attributes |
||
132 | * @param array $defaults |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 6 | public static function parseAttributeDefaults(array $attributes, array $defaults = array()) |
|
145 | |||
146 | /** |
||
147 | * Parse location string into components. |
||
148 | * |
||
149 | * @param string $location |
||
150 | * |
||
151 | * @return array |
||
152 | **/ |
||
153 | 2 | public static function parseLocation($location, $separator = ', ') |
|
157 | |||
158 | /** |
||
159 | * Sets http client |
||
160 | * |
||
161 | * @param HttpClient $client |
||
162 | * |
||
163 | * @return AbstractProvider |
||
164 | */ |
||
165 | 16 | public function setClient(HttpClient $client) |
|
171 | |||
172 | /** |
||
173 | * Sets query object |
||
174 | * |
||
175 | * @param AbstractQuery $query |
||
176 | * |
||
177 | * @return AbstractProvider |
||
178 | */ |
||
179 | 16 | public function setQuery(AbstractQuery $query) |
|
185 | |||
186 | /** |
||
187 | * Create and get collection of jobs from given listings |
||
188 | * |
||
189 | * @param array $listings |
||
190 | * |
||
191 | * @return Collection |
||
192 | */ |
||
193 | 4 | protected function getJobsCollectionFromListings(array $listings = []) |
|
210 | |||
211 | /** |
||
212 | * Get raw listings from payload |
||
213 | * |
||
214 | * @param array $payload |
||
215 | * |
||
216 | * @return array |
||
217 | */ |
||
218 | 4 | protected function getRawListings(array $payload = array()) |
|
236 | |||
237 | /** |
||
238 | * Navigate through a payload array looking for a particular index |
||
239 | * |
||
240 | * @param array $index The index sequence we are navigating down |
||
241 | * @param array $value The portion of the config array to process |
||
242 | * |
||
243 | * @return mixed |
||
244 | */ |
||
245 | 4 | protected static function getValue($index, $value) |
|
262 | |||
263 | /** |
||
264 | * Attempt to parse string as given format |
||
265 | * |
||
266 | * @param string $string |
||
267 | * @param string $format |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | 4 | protected function parseAsFormat($string, $format) |
|
281 | |||
282 | /** |
||
283 | * Get value current index |
||
284 | * |
||
285 | * @param mixed $index |
||
286 | * |
||
287 | * @return array|null |
||
288 | */ |
||
289 | 4 | private static function getValueCurrentIndex(&$index) |
|
293 | |||
294 | /** |
||
295 | * Checks if given value is an array and that it has contents |
||
296 | * |
||
297 | * @param mixed $array |
||
298 | * |
||
299 | * @return boolean |
||
300 | */ |
||
301 | 4 | private static function isArrayNotEmpty($array) |
|
305 | |||
306 | /** |
||
307 | * Attempt to parse as Json |
||
308 | * |
||
309 | * @param string $string |
||
310 | * |
||
311 | * @return array |
||
312 | */ |
||
313 | 4 | private function parseAsJson($string) |
|
329 | |||
330 | /** |
||
331 | * Attempt to parse as XML |
||
332 | * |
||
333 | * @param string $string |
||
334 | * |
||
335 | * @return array |
||
336 | */ |
||
337 | private function parseAsXml($string) |
||
356 | } |
||
357 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.