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 |
||
16 | class TValueTermReferenceExpressionType extends IsOK |
||
17 | { |
||
18 | use GExpressionTrait, TQualifiedNameTrait, TSimpleIdentifierTrait; |
||
19 | /** |
||
20 | * @property string $term |
||
21 | */ |
||
22 | private $term = null; |
||
23 | |||
24 | /** |
||
25 | * @property string $qualifier |
||
26 | */ |
||
27 | private $qualifier = null; |
||
28 | |||
29 | /** |
||
30 | * Gets as term |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | public function getTerm() |
||
38 | |||
39 | public function __construct() |
||
44 | |||
45 | /** |
||
46 | * Sets a new term |
||
47 | * |
||
48 | * @param string $term |
||
49 | * @return self |
||
50 | */ |
||
51 | public function setTerm($term) |
||
56 | |||
57 | /** |
||
58 | * Gets as qualifier |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getQualifier() |
||
66 | |||
67 | /** |
||
68 | * Sets a new qualifier |
||
69 | * |
||
70 | * @param string $qualifier |
||
71 | * @return self |
||
72 | */ |
||
73 | public function setQualifier($qualifier) |
||
78 | |||
79 | View Code Duplication | public function isOK(&$msg = null) |
|
95 | } |
||
96 |
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.