Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class FacebookServiceAdapter extends AbstractServiceAdapter |
||
16 | { |
||
17 | const THUMBNAIL_SIZE_DEFAULT = 'default'; |
||
18 | |||
19 | /** |
||
20 | * AbstractVideoAdapter constructor. |
||
21 | * |
||
22 | * @param string $url |
||
23 | * @param string $pattern |
||
24 | * @param EmbedRendererInterface $renderer |
||
25 | */ |
||
26 | public function __construct($url, $pattern, EmbedRendererInterface $renderer) |
||
34 | |||
35 | /** |
||
36 | * Returns the service name . |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getServiceName() |
||
44 | |||
45 | /** |
||
46 | * Returns if the service has a thumbnail image. |
||
47 | * |
||
48 | * @return bool |
||
49 | */ |
||
50 | public function hasThumbnail() |
||
54 | |||
55 | /** |
||
56 | * Returns all thumbnails available sizes. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function getThumbNailSizes() |
||
64 | |||
65 | /** |
||
66 | * @param string $size |
||
67 | * |
||
68 | * @param bool $forceSecure |
||
69 | * @return string |
||
70 | * @throws InvalidThumbnailSizeException |
||
71 | */ |
||
72 | View Code Duplication | public function getThumbnail($size, $forceSecure = false) |
|
80 | |||
81 | /** |
||
82 | * Returns the small thumbnail's url. |
||
83 | * |
||
84 | * @param bool $forceSecure |
||
85 | * @return string |
||
86 | * @throws ThumbnailSizeNotAvailable |
||
87 | */ |
||
88 | public function getSmallThumbnail($forceSecure = false) |
||
92 | |||
93 | /** |
||
94 | * Returns the medium thumbnail's url. |
||
95 | * |
||
96 | * @param bool $forceSecure |
||
97 | * @return string |
||
98 | * @throws InvalidThumbnailSizeException |
||
99 | */ |
||
100 | public function getMediumThumbnail($forceSecure = false) |
||
104 | |||
105 | /** |
||
106 | * Returns the large thumbnail's url. |
||
107 | * |
||
108 | * @param bool $forceSecure |
||
109 | * @return string |
||
110 | * @throws ThumbnailSizeNotAvailable |
||
111 | */ |
||
112 | public function getLargeThumbnail($forceSecure = false) |
||
116 | |||
117 | /** |
||
118 | * Returns the largest thumbnail's url. |
||
119 | * |
||
120 | * @param bool $forceSecure |
||
121 | * @return string |
||
122 | * @throws InvalidThumbnailSizeException |
||
123 | */ |
||
124 | public function getLargestThumbnail($forceSecure = false) |
||
128 | |||
129 | /** |
||
130 | * @param bool $forceAutoplay |
||
131 | * |
||
132 | * @param bool $forceSecure |
||
133 | * @return string |
||
134 | */ |
||
135 | public function getEmbedUrl($forceAutoplay = false, $forceSecure = false) |
||
139 | |||
140 | /** |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function isEmbeddable() |
||
147 | } |
||
148 |