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 |
||
15 | final class RulesetFileSystem implements RulesetFileSystemInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $vendorDir; |
||
21 | |||
22 | /** |
||
23 | * @var strings[] |
||
24 | */ |
||
25 | private $rulesets; |
||
26 | |||
27 | /** |
||
28 | * @param string $vendorDir |
||
29 | */ |
||
30 | 5 | public function __construct($vendorDir) |
|
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 2 | public function getRulesetPathForStandardName($standardName) |
|
52 | |||
53 | /** |
||
54 | * @return array |
||
55 | */ |
||
56 | 2 | private function getRulesets() |
|
71 | |||
72 | /** |
||
73 | * @return string[] |
||
74 | */ |
||
75 | 2 | View Code Duplication | private function findRulesetFiles() |
83 | |||
84 | /** |
||
85 | * @return string[] |
||
86 | */ |
||
87 | private function getRulesetNames() |
||
91 | } |
||
92 |