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 |
||
17 | class TValueAnnotationType extends IsOK |
||
18 | { |
||
19 | use GInlineExpressionsTrait, GExpressionTrait, TSimpleIdentifierTrait, TQualifiedNameTrait; |
||
20 | /** |
||
21 | * @property string $term |
||
22 | */ |
||
23 | private $term = null; |
||
24 | |||
25 | /** |
||
26 | * @property string $qualifier |
||
27 | */ |
||
28 | private $qualifier = null; |
||
29 | |||
30 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Gets as term |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getTerm() |
||
45 | |||
46 | /** |
||
47 | * Sets a new term |
||
48 | * |
||
49 | * @param string $term |
||
50 | * @return self |
||
51 | */ |
||
52 | public function setTerm($term) |
||
57 | |||
58 | /** |
||
59 | * Gets as qualifier |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getQualifier() |
||
67 | |||
68 | /** |
||
69 | * Sets a new qualifier |
||
70 | * |
||
71 | * @param string $qualifier |
||
72 | * @return self |
||
73 | */ |
||
74 | public function setQualifier($qualifier) |
||
79 | |||
80 | View Code Duplication | public function isOK(&$msg = null) |
|
99 | } |
||
100 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.