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 |
||
20 | class RandomQuoteUtilities |
||
|
|||
21 | { |
||
22 | |||
23 | /***************Blocks************** |
||
24 | * @param $cats |
||
25 | * @return string |
||
26 | */ |
||
27 | public static function randomquote_block_addCatSelect($cats) |
||
41 | |||
42 | /** |
||
43 | * @param $global |
||
44 | * @param $key |
||
45 | * @param string $default |
||
46 | * @param string $type |
||
47 | * @return mixed|string |
||
48 | */ |
||
49 | public static function cleanVarsRandomquote(&$global, $key, $default = '', $type = 'int') |
||
66 | |||
67 | /** |
||
68 | * @param $content |
||
69 | */ |
||
70 | View Code Duplication | public static function setMetaKeywordsRandomquote($content) |
|
81 | |||
82 | /** |
||
83 | * @param $content |
||
84 | */ |
||
85 | View Code Duplication | public static function setMetaDescriptionRandomquote($content) |
|
96 | } |
||
97 |
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.