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 |
||
14 | class UnderscoredClassNamespacePrefix extends UnderscoreNamingStrategy |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $map; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $whitelist; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $blacklist; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $joinTableFieldSuffix; |
||
35 | |||
36 | 16 | public function __construct(array $configuration = array()) |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 14 | public function classToTableName($className) |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 2 | View Code Duplication | public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) |
77 | |||
78 | /** |
||
79 | * Find prefix for table from map. |
||
80 | * |
||
81 | * @param string $className |
||
82 | * @return string |
||
83 | */ |
||
84 | 14 | private function getTableNamePrefix($className) |
|
117 | } |
||
118 |
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.