1 | <?php namespace JobApis\Jobs\Client\Providers; |
||
5 | class UsajobsProvider extends AbstractProvider |
||
6 | { |
||
7 | /** |
||
8 | * Returns the standardized job object |
||
9 | * |
||
10 | * NOTE: The following properties are not being set: |
||
11 | * PositionID |
||
12 | * DepartmentName |
||
13 | * ApplyURI |
||
14 | * UserArea |
||
15 | * |
||
16 | * @param array $payload Raw job payload from the API |
||
17 | * |
||
18 | * @return \JobApis\Jobs\Client\Job |
||
19 | */ |
||
20 | 4 | public function createJobObject($payload = []) |
|
40 | |||
41 | /** |
||
42 | * Job response object default keys that should be set |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | 4 | public function getDefaultResponseFields() |
|
53 | |||
54 | /** |
||
55 | * Get listings path |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 4 | public function getListingsPath() |
|
63 | |||
64 | /** |
||
65 | * Sets nested properties |
||
66 | * |
||
67 | * @param $payload array |
||
68 | * @param $job \JobApis\Jobs\Client\Job |
||
69 | * |
||
70 | * @return \JobApis\Jobs\Client\Job |
||
71 | */ |
||
72 | 4 | protected function setDates($payload, $job) |
|
88 | |||
89 | /** |
||
90 | * Sets nested properties |
||
91 | * |
||
92 | * @param $payload array |
||
93 | * @param $job \JobApis\Jobs\Client\Job |
||
94 | * |
||
95 | * @return \JobApis\Jobs\Client\Job |
||
96 | */ |
||
97 | 4 | protected function setNestedProperties($payload, $job) |
|
129 | |||
130 | /** |
||
131 | * Parses the salary range and adds it to the job |
||
132 | * |
||
133 | * @param $salaries array |
||
134 | * @param $job \JobApis\Jobs\Client\Job |
||
135 | * |
||
136 | * @return \JobApis\Jobs\Client\Job |
||
137 | */ |
||
138 | 4 | protected function setSalary($salaries, $job) |
|
149 | |||
150 | /** |
||
151 | * Parses the location and attaches it to the job |
||
152 | * |
||
153 | * @param $locations array |
||
154 | * @param $job \JobApis\Jobs\Client\Job |
||
155 | * |
||
156 | * @return \JobApis\Jobs\Client\Job |
||
157 | */ |
||
158 | 4 | protected function setLocation($locations, $job) |
|
182 | } |
||
183 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.