Total Complexity | 74 |
Total Lines | 437 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like JobPosterNonLocalized often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use JobPosterNonLocalized, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
9 | class JobPosterNonLocalized implements JsonSerializable { |
||
|
|||
10 | |||
11 | private $id; |
||
12 | private $manager_user_id; |
||
13 | private $title_en; |
||
14 | private $title_fr; |
||
15 | private $department_id; |
||
16 | private $province_id; |
||
17 | private $branch_en; |
||
18 | private $branch_fr; |
||
19 | private $division_en; |
||
20 | private $division_fr; |
||
21 | private $city_en; |
||
22 | private $city_fr; |
||
23 | private $term_qty; |
||
24 | private $term_units_id; |
||
25 | private $open_date; |
||
26 | private $close_date; |
||
27 | private $start_date; |
||
28 | private $remuneration_range_low; |
||
29 | private $remuneration_range_high; |
||
30 | private $job_min_level_id; |
||
31 | private $job_max_level_id; |
||
32 | private $impact_en; |
||
33 | private $impact_fr; |
||
34 | private $key_tasks_en; |
||
35 | private $key_tasks_fr; |
||
36 | private $core_competencies_en; |
||
37 | private $core_competencies_fr; |
||
38 | private $developing_competencies_en; |
||
39 | private $developing_competencies_fr; |
||
40 | private $questions_en; |
||
41 | private $questions_fr; |
||
42 | private $noc; |
||
43 | private $classification; |
||
44 | private $clearance_id; |
||
45 | private $language_id; |
||
46 | |||
47 | public function __construct( |
||
48 | $id = null, |
||
49 | $manager_user_id = null, |
||
50 | $title_en = null, |
||
51 | $title_fr = null, |
||
52 | $department_id = null, |
||
53 | $province_id = null, |
||
54 | $branch_en = null, |
||
55 | $branch_fr = null, |
||
56 | $division_en = null, |
||
57 | $division_fr = null, |
||
58 | $city_en = null, |
||
59 | $city_fr = null, |
||
60 | $term_qty = null, |
||
61 | $term_units_id = null, |
||
62 | $open_date = null, |
||
63 | $close_date = null, |
||
64 | $start_date = null, |
||
65 | $remuneration_range_low = null, |
||
66 | $remuneration_range_high = null, |
||
67 | $job_min_level_id = null, |
||
68 | $job_max_level_id = null, |
||
69 | $impact_en = null, |
||
70 | $impact_fr = null, |
||
71 | $key_tasks_en = null, |
||
72 | $key_tasks_fr = null, |
||
73 | $core_competencies_en = null, |
||
74 | $core_competencies_fr = null, |
||
75 | $developing_competencies_en = null, |
||
76 | $developing_competencies_fr = null, |
||
77 | $questions_en = [], |
||
78 | $questions_fr = [], |
||
79 | $noc = null, |
||
80 | $classification = null, |
||
81 | $clearance_id = null, |
||
82 | $language_id = null |
||
83 | ) { |
||
84 | $this->id = $id; |
||
85 | $this->manager_user_id = $manager_user_id; |
||
86 | $this->title_en = $title_en; |
||
87 | $this->title_fr = $title_fr; |
||
88 | $this->department_id = $department_id; |
||
89 | $this->province_id = $province_id; |
||
90 | $this->branch_en = $branch_en; |
||
91 | $this->branch_fr = $branch_fr; |
||
92 | $this->division_en = $division_en; |
||
93 | $this->division_fr = $division_fr; |
||
94 | $this->city_en = $city_en; |
||
95 | $this->city_fr = $city_fr; |
||
96 | $this->term_qty = $term_qty; |
||
97 | $this->term_units_id = $term_units_id; |
||
98 | $this->open_date = $open_date; |
||
99 | $this->close_date = $close_date; |
||
100 | $this->start_date = $start_date; |
||
101 | $this->remuneration_range_low = $remuneration_range_low; |
||
102 | $this->remuneration_range_high = $remuneration_range_high; |
||
103 | $this->job_min_level_id = $job_min_level_id; |
||
104 | $this->job_max_level_id = $job_max_level_id; |
||
105 | $this->impact_en = $impact_en; |
||
106 | $this->impact_fr = $impact_fr; |
||
107 | $this->key_tasks_en = $key_tasks_en; |
||
108 | $this->key_tasks_fr = $key_tasks_fr; |
||
109 | $this->core_competencies_en = $core_competencies_en; |
||
110 | $this->core_competencies_fr = $core_competencies_fr; |
||
111 | $this->developing_competencies_en = $developing_competencies_en; |
||
112 | $this->developing_competencies_fr = $developing_competencies_fr; |
||
113 | $this->questions_en = $questions_en; |
||
114 | $this->questions_fr = $questions_fr; |
||
115 | $this->noc = $noc; |
||
116 | $this->classification = $classification; |
||
117 | $this->clearance_id = $clearance_id; |
||
118 | $this->language_id = $language_id; |
||
119 | } |
||
120 | |||
121 | |||
122 | public function jsonSerialize() { |
||
123 | $getter_names = get_class_methods(get_class($this)); |
||
124 | $gettable_attributes = array(); |
||
125 | foreach ($getter_names as $key => $value) { |
||
126 | if (substr($value, 0, 3) === 'get') { |
||
127 | $gettable_attributes[strtolower(substr($value, 3, strlen($value)))] = $this->$value(); |
||
128 | } |
||
129 | } |
||
130 | return $gettable_attributes; |
||
131 | } |
||
132 | |||
133 | public function getId() { |
||
134 | return $this->id; |
||
135 | } |
||
136 | |||
137 | public function getManager_user_id() { |
||
138 | return $this->manager_user_id; |
||
139 | } |
||
140 | |||
141 | public function getTitle_en() { |
||
142 | return $this->title_en; |
||
143 | } |
||
144 | |||
145 | public function getTitle_fr() { |
||
147 | } |
||
148 | |||
149 | public function getDepartment_id() { |
||
150 | return $this->department_id; |
||
151 | } |
||
152 | |||
153 | public function getProvince_id() { |
||
154 | return $this->province_id; |
||
155 | } |
||
156 | |||
157 | public function getBranch_en() { |
||
158 | return $this->branch_en; |
||
159 | } |
||
160 | |||
161 | public function getBranch_fr() { |
||
162 | return $this->branch_fr; |
||
163 | } |
||
164 | |||
165 | public function getDivision_en() { |
||
166 | return $this->division_en; |
||
167 | } |
||
168 | |||
169 | public function getDivision_fr() { |
||
170 | return $this->division_fr; |
||
171 | } |
||
172 | |||
173 | public function getCity_en() { |
||
174 | return $this->city_en; |
||
175 | } |
||
176 | |||
177 | public function getCity_fr() { |
||
178 | return $this->city_fr; |
||
179 | } |
||
180 | |||
181 | public function getTerm_qty() { |
||
182 | return $this->term_qty; |
||
183 | } |
||
184 | |||
185 | public function getTerm_units_id() { |
||
186 | return $this->term_units_id; |
||
187 | } |
||
188 | |||
189 | public function getOpen_date() { |
||
190 | return $this->open_date; |
||
191 | } |
||
192 | |||
193 | public function getClose_date() { |
||
194 | return $this->close_date; |
||
195 | } |
||
196 | |||
197 | public function getStart_date() { |
||
198 | return $this->start_date; |
||
199 | } |
||
200 | |||
201 | public function getRemuneration_range_low() { |
||
202 | return $this->remuneration_range_low; |
||
203 | } |
||
204 | |||
205 | public function getRemuneration_range_high() { |
||
206 | return $this->remuneration_range_high; |
||
207 | } |
||
208 | |||
209 | public function getJob_min_level_id() { |
||
210 | return $this->job_min_level_id; |
||
211 | } |
||
212 | |||
213 | public function getJob_max_level_id() { |
||
214 | return $this->job_max_level_id; |
||
215 | } |
||
216 | |||
217 | public function getImpact_en() { |
||
218 | return $this->impact_en; |
||
219 | } |
||
220 | |||
221 | public function getImpact_fr() { |
||
222 | return $this->impact_fr; |
||
223 | } |
||
224 | |||
225 | public function getKey_tasks_en() { |
||
227 | } |
||
228 | |||
229 | public function getKey_tasks_fr() { |
||
230 | return $this->key_tasks_fr; |
||
231 | } |
||
232 | |||
233 | public function getCore_competencies_en() { |
||
234 | return $this->core_competencies_en; |
||
235 | } |
||
236 | |||
237 | public function getCore_competencies_fr() { |
||
238 | return $this->core_competencies_fr; |
||
239 | } |
||
240 | |||
241 | public function getDeveloping_competencies_en() { |
||
242 | return $this->developing_competencies_en; |
||
243 | } |
||
244 | |||
245 | public function getDeveloping_competencies_fr() { |
||
246 | return $this->developing_competencies_fr; |
||
247 | } |
||
248 | |||
249 | public function getQuestions_en() { |
||
251 | } |
||
252 | |||
253 | public function getQuestions_fr() { |
||
254 | return $this->questions_fr; |
||
255 | } |
||
256 | |||
257 | public function getNoc() { |
||
258 | return $this->noc; |
||
259 | } |
||
260 | |||
261 | public function getClassification() { |
||
262 | return $this->classification; |
||
263 | } |
||
264 | |||
265 | public function getClearance_id() { |
||
266 | return $this->clearance_id; |
||
267 | } |
||
268 | |||
269 | public function getLanguage_id() { |
||
270 | return $this->language_id; |
||
271 | } |
||
272 | |||
273 | public function setId($id) { |
||
274 | $this->id = $id; |
||
275 | return $this; |
||
276 | } |
||
277 | |||
278 | public function setManager_user_id($manager_user_id) { |
||
279 | $this->manager_user_id = $manager_user_id; |
||
280 | return $this; |
||
281 | } |
||
282 | |||
283 | public function setTitle_en($title_en) { |
||
284 | $this->title_en = $title_en; |
||
285 | return $this; |
||
286 | } |
||
287 | |||
288 | public function setTitle_fr($title_fr) { |
||
289 | $this->title_fr = $title_fr; |
||
290 | return $this; |
||
291 | } |
||
292 | |||
293 | public function setDepartment_id($department_id) { |
||
294 | $this->department_id = $department_id; |
||
295 | return $this; |
||
296 | } |
||
297 | |||
298 | public function setProvince_id($province_id) { |
||
299 | $this->province_id = $province_id; |
||
300 | return $this; |
||
301 | } |
||
302 | |||
303 | public function setBranch_en($branch_en) { |
||
304 | $this->branch_en = $branch_en; |
||
305 | return $this; |
||
306 | } |
||
307 | |||
308 | public function setBranch_fr($branch_fr) { |
||
309 | $this->branch_fr = $branch_fr; |
||
310 | return $this; |
||
311 | } |
||
312 | |||
313 | public function setDivision_en($division_en) { |
||
314 | $this->division_en = $division_en; |
||
315 | return $this; |
||
316 | } |
||
317 | |||
318 | public function setDivision_fr($division_fr) { |
||
319 | $this->division_fr = $division_fr; |
||
320 | return $this; |
||
321 | } |
||
322 | |||
323 | public function setCity_en($city_en) { |
||
324 | $this->city_en = $city_en; |
||
325 | return $this; |
||
326 | } |
||
327 | |||
328 | public function setCity_fr($city_fr) { |
||
329 | $this->city_fr = $city_fr; |
||
330 | return $this; |
||
331 | } |
||
332 | |||
333 | public function setTerm_qty($term_qty) { |
||
334 | $this->term_qty = $term_qty; |
||
335 | return $this; |
||
336 | } |
||
337 | |||
338 | public function setTerm_units_id($term_units_id) { |
||
339 | $this->term_units_id = $term_units_id; |
||
340 | return $this; |
||
341 | } |
||
342 | |||
343 | public function setOpen_date($open_date) { |
||
344 | $this->open_date = $open_date; |
||
345 | return $this; |
||
346 | } |
||
347 | |||
348 | public function setClose_date($close_date) { |
||
349 | $this->close_date = $close_date; |
||
350 | return $this; |
||
351 | } |
||
352 | |||
353 | public function setStart_date($start_date) { |
||
354 | $this->start_date = $start_date; |
||
355 | return $this; |
||
356 | } |
||
357 | |||
358 | public function setRemuneration_range_low($remuneration_range_low) { |
||
359 | $this->remuneration_range_low = $remuneration_range_low; |
||
360 | return $this; |
||
361 | } |
||
362 | |||
363 | public function setRemuneration_range_high($remuneration_range_high) { |
||
364 | $this->remuneration_range_high = $remuneration_range_high; |
||
365 | return $this; |
||
366 | } |
||
367 | |||
368 | public function setJob_min_level_id($job_min_level_id) { |
||
369 | $this->job_min_level_id = $job_min_level_id; |
||
370 | return $this; |
||
371 | } |
||
372 | |||
373 | public function setJob_max_level_id($job_max_level_id) { |
||
374 | $this->job_max_level_id = $job_max_level_id; |
||
375 | return $this; |
||
376 | } |
||
377 | |||
378 | public function setImpact_en($impact_en) { |
||
379 | $this->impact_en = $impact_en; |
||
380 | return $this; |
||
381 | } |
||
382 | |||
383 | public function setImpact_fr($impact_fr) { |
||
384 | $this->impact_fr = $impact_fr; |
||
385 | return $this; |
||
386 | } |
||
387 | |||
388 | public function setKey_tasks_en($key_tasks_en) { |
||
389 | $this->key_tasks_en = $key_tasks_en; |
||
390 | return $this; |
||
391 | } |
||
392 | |||
393 | public function setKey_tasks_fr($key_tasks_fr) { |
||
394 | $this->key_tasks_fr = $key_tasks_fr; |
||
395 | return $this; |
||
396 | } |
||
397 | |||
398 | public function setCore_competencies_en($core_competencies_en) { |
||
399 | $this->core_competencies_en = $core_competencies_en; |
||
400 | return $this; |
||
401 | } |
||
402 | |||
403 | public function setCore_competencies_fr($core_competencies_fr) { |
||
404 | $this->core_competencies_fr = $core_competencies_fr; |
||
405 | return $this; |
||
406 | } |
||
407 | |||
408 | public function setDeveloping_competencies_en($developing_competencies_en) { |
||
409 | $this->developing_competencies_en = $developing_competencies_en; |
||
410 | return $this; |
||
411 | } |
||
412 | |||
413 | public function setDeveloping_competencies_fr($developing_competencies_fr) { |
||
414 | $this->developing_competencies_fr = $developing_competencies_fr; |
||
415 | return $this; |
||
416 | } |
||
417 | |||
418 | public function setQuestions_en($questions_en) { |
||
419 | $this->questions_en = $questions_en; |
||
420 | return $this; |
||
421 | } |
||
422 | |||
423 | public function setQuestions_fr($questions_fr) { |
||
424 | $this->questions_fr = $questions_fr; |
||
425 | return $this; |
||
426 | } |
||
427 | |||
428 | public function setNoc($noc) { |
||
431 | } |
||
432 | |||
433 | public function setClassification($classification) { |
||
434 | $this->classification = $classification; |
||
435 | return $this; |
||
436 | } |
||
437 | |||
438 | public function setClearance_id($clearance_id) { |
||
439 | $this->clearance_id = $clearance_id; |
||
440 | return $this; |
||
441 | } |
||
442 | |||
443 | public function setLanguage_id($language_id) { |
||
444 | $this->language_id = $language_id; |
||
445 | return $this; |
||
446 | } |
||
447 | |||
448 | } |
||
449 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.