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 |
||
23 | class IndexConfig implements IndexConfigInterface |
||
24 | { |
||
25 | use IndexConfigTrait; |
||
26 | |||
27 | /** |
||
28 | * Indicates if the index should use an alias, allowing an index repopulation to occur |
||
29 | * without overwriting the current index. |
||
30 | * |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $useAlias = false; |
||
34 | |||
35 | /** |
||
36 | * Constructor expects an array as generated by the Container Configuration builder. |
||
37 | * |
||
38 | * @param string $name |
||
39 | * @param TypeConfig[] $types |
||
40 | * @param array $config |
||
41 | */ |
||
42 | 27 | View Code Duplication | public function __construct($name, array $types, array $config) |
50 | |||
51 | /** |
||
52 | * @return bool |
||
53 | */ |
||
54 | 13 | public function isUseAlias() |
|
58 | } |
||
59 |