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 |
||
40 | class MylinksPagepeeker implements MylinksThumbPlugin |
||
41 | { |
||
42 | private $image_width = 0; |
||
43 | private $image_height = 0; |
||
44 | private $image_size = 'm'; |
||
45 | private $site_url = null; |
||
46 | private $key = null; |
||
47 | private $attribution = "<a href=\"http://www.pagepeeker.com\" target=\"_blank\" title=\"Thumbnail Screenshots by PagePeeker\">Thumbnail Screenshots by PagePeeker</a>"; |
||
48 | private $provider_url = 'http://free.pagepeeker.com/v2/thumbs.php'; |
||
49 | private $provider_name = 'Pagepeeker'; |
||
50 | protected $_dirname = null; |
||
51 | |||
52 | /** |
||
53 | * MylinksPagepeeker constructor. |
||
54 | */ |
||
55 | public function __construct() |
||
60 | |||
61 | /** |
||
62 | * @return mixed|string |
||
63 | */ |
||
64 | public function getProviderUrl() |
||
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | public function getProviderName() |
||
101 | |||
102 | /** |
||
103 | * @param $sz |
||
104 | * @return mixed|void |
||
105 | */ |
||
106 | public function setShotSize($sz) |
||
147 | |||
148 | /** |
||
149 | * @return array |
||
150 | */ |
||
151 | public function getShotSize() |
||
155 | |||
156 | /** |
||
157 | * @param $url |
||
158 | * @return mixed|void |
||
159 | */ |
||
160 | public function setSiteUrl($url) |
||
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getSiteUrl() |
||
173 | |||
174 | /** |
||
175 | * @param null $attr |
||
176 | */ |
||
177 | public function setAttribution($attr = null) |
||
181 | |||
182 | /** |
||
183 | * @param int $allowhtml |
||
184 | * @return string |
||
185 | */ |
||
186 | public function getAttribution($allowhtml = 0) |
||
196 | |||
197 | /** |
||
198 | * @param $key |
||
199 | * @return mixed|void |
||
200 | */ |
||
201 | public function setProviderPublicKey($key) |
||
205 | |||
206 | /** |
||
207 | * @return null |
||
208 | */ |
||
209 | public function getProviderPublicKey() |
||
213 | |||
214 | /** |
||
215 | * @param $key |
||
216 | * @return bool |
||
217 | */ |
||
218 | public function setProviderPrivateKey($key) |
||
222 | |||
223 | /** |
||
224 | * @return bool |
||
225 | */ |
||
226 | public function getProviderPrivateKey() |
||
230 | } |
||
231 |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.