1 | <?php namespace JobApis\Jobs\Client\Providers; |
||
5 | class MuseProvider 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 | 4 | public function createJobObject($payload = []) |
|
38 | |||
39 | /** |
||
40 | * Job response object default keys that should be set |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 4 | public function getDefaultResponseFields() |
|
62 | |||
63 | /** |
||
64 | * Get listings path |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 4 | public function getListingsPath() |
|
72 | |||
73 | /** |
||
74 | * Sets the categories on the job using the categories array |
||
75 | * |
||
76 | * @param Job $job |
||
77 | * @param array $categories |
||
78 | * |
||
79 | * @return MuseProvider |
||
80 | */ |
||
81 | 4 | protected function setCategories(Job $job, $categories = []) |
|
92 | |||
93 | /** |
||
94 | * Sets the company on the job using the company array |
||
95 | * |
||
96 | * @param Job $job |
||
97 | * @param array $company |
||
98 | * |
||
99 | * @return MuseProvider |
||
100 | */ |
||
101 | 4 | protected function setCompany(Job $job, $company = []) |
|
108 | |||
109 | /** |
||
110 | * Sets the experience levels on the job using the levels array |
||
111 | * |
||
112 | * @param Job $job |
||
113 | * @param array $levels |
||
114 | * |
||
115 | * @return MuseProvider |
||
116 | */ |
||
117 | 4 | protected function setLevels(Job $job, $levels = []) |
|
128 | |||
129 | /** |
||
130 | * Sets the location on the job using the first location in the array |
||
131 | * |
||
132 | * @param Job $job |
||
133 | * @param array $locations |
||
134 | * |
||
135 | * @return MuseProvider |
||
136 | */ |
||
137 | 4 | protected function setLocation(Job $job, $locations = []) |
|
144 | } |
||
145 |
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.