1 | <?php namespace JobApis\Jobs\Client\Providers; |
||
5 | class CareerbuilderProvider extends AbstractProvider |
||
6 | { |
||
7 | /** |
||
8 | * Returns the standardized job object |
||
9 | * |
||
10 | * @param array $payload Raw job payload from the API |
||
11 | * |
||
12 | * @return \JobApis\Jobs\Client\Job |
||
13 | */ |
||
14 | 10 | public function createJobObject($payload = []) |
|
52 | |||
53 | /** |
||
54 | * Job response object default keys that should be set |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 4 | public function getDefaultResponseFields() |
|
81 | |||
82 | /** |
||
83 | * Get data format |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 4 | public function getFormat() |
|
91 | |||
92 | /** |
||
93 | * Get listings path |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 4 | public function getListingsPath() |
|
101 | |||
102 | /** |
||
103 | * Get min and max salary numbers from string |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | 22 | public function parseSalariesFromString($input = null) |
|
129 | |||
130 | /** |
||
131 | * Parse annual salary range from CB API |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 2 | protected function parseAnnualRange($salary = [], $input = null) |
|
144 | |||
145 | /** |
||
146 | * Parse fixed annual salary from CB API |
||
147 | * |
||
148 | * @return array |
||
149 | */ |
||
150 | 2 | protected function parseAnnualFixed($salary = [], $input = null) |
|
158 | |||
159 | /** |
||
160 | * Parse hourly payrate range from CB API |
||
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | 2 | protected function parseHourlyRange($salary = [], $input = null) |
|
173 | |||
174 | /** |
||
175 | * Parse fixed hourly payrate from CB API |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | protected function parseHourlyFixed($salary = [], $input = null) |
||
187 | |||
188 | /** |
||
189 | * Makes sure that city/state is a string |
||
190 | * |
||
191 | * @param $element mixed |
||
192 | * |
||
193 | * @return string|null |
||
194 | */ |
||
195 | 10 | protected function parseLocationElement($element) |
|
202 | |||
203 | /** |
||
204 | * Parse skills array into string |
||
205 | * |
||
206 | * @return array |
||
207 | */ |
||
208 | 10 | protected function parseSkillSet($skills) |
|
217 | } |
||
218 |
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.