Complex classes like Video 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 Video, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
42 | class Video extends AbstractEntity |
||
43 | { |
||
44 | |||
45 | /** |
||
46 | * The title of the Video |
||
47 | * |
||
48 | * @var string |
||
49 | * @validate StringLength(minimum = 1) |
||
50 | */ |
||
51 | protected $title; |
||
52 | |||
53 | /** |
||
54 | * Vimeo Source Url |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $vimeo; |
||
59 | |||
60 | /** |
||
61 | * The description |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $description; |
||
66 | |||
67 | /** |
||
68 | * The posterimage of the Video |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $posterimage; |
||
73 | |||
74 | /** |
||
75 | * The mp4source of the Video |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $mp4source; |
||
80 | |||
81 | /** |
||
82 | * The webmsource of the Video |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $webmsource; |
||
87 | |||
88 | /** |
||
89 | * The oggsource of the Video |
||
90 | * |
||
91 | * @var string |
||
92 | */ |
||
93 | protected $oggsource; |
||
94 | |||
95 | /** |
||
96 | * The height of the Video |
||
97 | * |
||
98 | * @var string |
||
99 | */ |
||
100 | protected $height; |
||
101 | |||
102 | /** |
||
103 | * The width of the Video |
||
104 | * |
||
105 | * @var string |
||
106 | */ |
||
107 | protected $width; |
||
108 | |||
109 | /** |
||
110 | * Show download links |
||
111 | * |
||
112 | * @var boolean |
||
113 | */ |
||
114 | protected $downloadlinks; |
||
115 | |||
116 | /** |
||
117 | * Show the support link |
||
118 | * |
||
119 | * @var boolean |
||
120 | */ |
||
121 | protected $supportvideojs; |
||
122 | |||
123 | /** |
||
124 | * Preload the video |
||
125 | * |
||
126 | * @var string |
||
127 | */ |
||
128 | protected $preloadvideo; |
||
129 | |||
130 | /** |
||
131 | * Autoplay the video |
||
132 | * |
||
133 | * @var boolean |
||
134 | */ |
||
135 | protected $autoplayvideo; |
||
136 | |||
137 | /** |
||
138 | * Mute the video |
||
139 | * |
||
140 | * @var boolean |
||
141 | */ |
||
142 | protected $mutevideo; |
||
143 | |||
144 | /** |
||
145 | * Loop the video |
||
146 | * |
||
147 | * @var boolean |
||
148 | */ |
||
149 | protected $loopvideo; |
||
150 | |||
151 | /** |
||
152 | * Start time of the video (in s) |
||
153 | * |
||
154 | * @var integer |
||
155 | */ |
||
156 | protected $videoStarttime; |
||
157 | |||
158 | /** |
||
159 | * |
||
160 | * @var boolean |
||
161 | */ |
||
162 | protected $controlsvideo; |
||
163 | |||
164 | /** |
||
165 | * |
||
166 | * @var string |
||
167 | */ |
||
168 | protected $youtube; |
||
169 | |||
170 | /** |
||
171 | * Returns the $title |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getTitle() |
||
179 | |||
180 | /** |
||
181 | * Set the title of the Video |
||
182 | * |
||
183 | * @param string $title the $title to set |
||
184 | */ |
||
185 | public function setTitle($title) |
||
189 | |||
190 | /** |
||
191 | * Returns the $posterimage |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getPosterimage() |
||
199 | |||
200 | /** |
||
201 | * Set the posterimage of the Video |
||
202 | * |
||
203 | * @param string $posterimage the $posterimage to set |
||
204 | */ |
||
205 | public function setPosterimage($posterimage) |
||
209 | |||
210 | /** |
||
211 | * Returns the $mp4source |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getMp4source() |
||
219 | |||
220 | /** |
||
221 | * Set the mp4source of the Video |
||
222 | * |
||
223 | * @param string $mp4source the $mp4source to set |
||
224 | */ |
||
225 | public function setMp4source($mp4source) |
||
229 | |||
230 | /** |
||
231 | * Returns the $webmsource |
||
232 | * |
||
233 | * @return string |
||
234 | */ |
||
235 | public function getWebmsource() |
||
239 | |||
240 | /** |
||
241 | * Set the webmsource of the Video |
||
242 | * |
||
243 | * @param string $webmsource the $webmsource to set |
||
244 | */ |
||
245 | public function setWebmsource($webmsource) |
||
249 | |||
250 | /** |
||
251 | * Returns the $oggsource |
||
252 | * |
||
253 | * @return string |
||
254 | */ |
||
255 | public function getOggsource() |
||
259 | |||
260 | /** |
||
261 | * Set the oggsource of the Video |
||
262 | * |
||
263 | * @param string $oggsource the $oggsource to set |
||
264 | */ |
||
265 | public function setOggsource($oggsource) |
||
269 | |||
270 | /** |
||
271 | * Returns the $height |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | public function getHeight() |
||
279 | |||
280 | /** |
||
281 | * Set the height of the Video |
||
282 | * |
||
283 | * @param string $height the $height to set |
||
284 | */ |
||
285 | public function setHeight($height) |
||
289 | |||
290 | /** |
||
291 | * Returns the $width |
||
292 | * |
||
293 | * @return string |
||
294 | */ |
||
295 | public function getWidth() |
||
299 | |||
300 | /** |
||
301 | * Set the width of the Video |
||
302 | * |
||
303 | * @param string $width the $width to set |
||
304 | */ |
||
305 | public function setWidth($width) |
||
309 | |||
310 | /** |
||
311 | * Returns the $downloadlinks |
||
312 | * |
||
313 | * @return string |
||
314 | */ |
||
315 | public function getDownloadlinks() |
||
319 | |||
320 | /** |
||
321 | * Set the downloadlinks of the Video |
||
322 | * |
||
323 | * @param boolean $downloadlinks the $downloadlinks to set |
||
324 | */ |
||
325 | public function setDownloadlinks($downloadlinks) |
||
329 | |||
330 | /** |
||
331 | * Returns the $supportvideojs |
||
332 | * |
||
333 | * @return string |
||
334 | */ |
||
335 | public function getSupportvideojs() |
||
339 | |||
340 | /** |
||
341 | * Set the supportvideojs of the Video |
||
342 | * |
||
343 | * @param boolean $supportvideojs the $supportvideojs to set |
||
344 | */ |
||
345 | public function setSupportvideojs($supportvideojs) |
||
349 | |||
350 | /** |
||
351 | * Returns the $preloadvideo |
||
352 | * |
||
353 | * @return string |
||
354 | */ |
||
355 | public function getPreloadvideo() |
||
359 | |||
360 | /** |
||
361 | * Set the preloadvideo of the Video |
||
362 | * |
||
363 | * @param string $preloadvideo the $preloadvideo to set |
||
364 | */ |
||
365 | public function setPreloadvideo($preloadvideo) |
||
369 | |||
370 | /** |
||
371 | * Returns the $autoplayvideo |
||
372 | * |
||
373 | * @return string |
||
374 | */ |
||
375 | public function getAutoplayvideo() |
||
379 | |||
380 | /** |
||
381 | * Set the autoplayvideo of the Video |
||
382 | * |
||
383 | * @param boolean $autoplayvideo the $autoplayvideo to set |
||
384 | */ |
||
385 | public function setAutoplayvideo($autoplayvideo) |
||
389 | |||
390 | /** |
||
391 | * @return int |
||
392 | */ |
||
393 | public function getVideoStarttime() |
||
397 | |||
398 | /** |
||
399 | * @param int $videoStarttime |
||
400 | */ |
||
401 | public function setVideoStarttime($videoStarttime) |
||
405 | |||
406 | /** |
||
407 | * |
||
408 | * @return boolean |
||
409 | */ |
||
410 | public function getControlsvideo() |
||
414 | |||
415 | /** |
||
416 | * |
||
417 | * @param boolean $controlsvideo |
||
418 | */ |
||
419 | public function setControlsvideo($controlsvideo) |
||
423 | |||
424 | /** |
||
425 | * |
||
426 | * @return string |
||
427 | */ |
||
428 | public function getDescription() |
||
432 | |||
433 | /** |
||
434 | * |
||
435 | * @param string $description |
||
436 | */ |
||
437 | public function setDescription($description) |
||
441 | |||
442 | /** |
||
443 | * @param boolean $loopvideo |
||
444 | */ |
||
445 | public function setLoopvideo($loopvideo) |
||
449 | |||
450 | /** |
||
451 | * @return boolean |
||
452 | */ |
||
453 | public function getLoopvideo() |
||
457 | |||
458 | /** |
||
459 | * Set the mute of the Video |
||
460 | * |
||
461 | * @param boolean $mutevideo |
||
462 | */ |
||
463 | public function setMutevideo($mutevideo) |
||
467 | |||
468 | /** |
||
469 | * Returns the $mutevideo |
||
470 | * |
||
471 | * @return boolean |
||
472 | */ |
||
473 | public function getMutevideo() |
||
477 | |||
478 | /** |
||
479 | * Resolves the URL of an file |
||
480 | * |
||
481 | * @param $media |
||
482 | * |
||
483 | * @return null|string |
||
484 | */ |
||
485 | protected function retrieveMediaUrl($media) |
||
556 | |||
557 | /** |
||
558 | * @param string $youtube |
||
559 | */ |
||
560 | public function setYoutube($youtube) |
||
564 | |||
565 | /** |
||
566 | * @return string |
||
567 | */ |
||
568 | public function getYoutube() |
||
572 | |||
573 | /** |
||
574 | * @param string $vimeo |
||
575 | */ |
||
576 | public function setVimeo($vimeo) |
||
580 | |||
581 | /** |
||
582 | * @return string |
||
583 | */ |
||
584 | public function getVimeo() |
||
588 | |||
589 | /** |
||
590 | * @return int|string |
||
591 | */ |
||
592 | public function getMinWidth() |
||
606 | |||
607 | /** |
||
608 | * @return int|string |
||
609 | */ |
||
610 | public function getMinHeight() |
||
624 | |||
625 | /** |
||
626 | * @return string |
||
627 | */ |
||
628 | public function getTechOrder() |
||
639 | } |
||
640 |