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 |
||
35 | View Code Duplication | class Stateless extends AbstractBeanAnnotation |
|
|
|||
36 | { |
||
37 | |||
38 | /** |
||
39 | * The value of the bean interface attribute. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $beanInterface; |
||
44 | |||
45 | /** |
||
46 | * The value of the bean name attribute. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $beanName; |
||
51 | |||
52 | /** |
||
53 | * The constructor the initializes the instance with the |
||
54 | * data passed with the token. |
||
55 | * |
||
56 | * @param array $values The annotation values |
||
57 | */ |
||
58 | public function __construct(array $values = array()) |
||
74 | |||
75 | /** |
||
76 | * Returns the value of the bean interface attribute. |
||
77 | * |
||
78 | * @return string|null The annotations bean interface attribute |
||
79 | */ |
||
80 | public function getBeanInterface() |
||
84 | |||
85 | /** |
||
86 | * Returns the value of the bean name attribute. |
||
87 | * |
||
88 | * @return string|null The annotations bean Name attribute |
||
89 | */ |
||
90 | public function getBeanName() |
||
94 | } |
||
95 |
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.