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 |
||
13 | class CriteriaCompilerPass extends AbstractCompilerPass |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | 2 | protected function processContext( |
|
36 | |||
37 | /** |
||
38 | * @param string $contextId |
||
39 | * @param array $criteria |
||
40 | * @param ContainerBuilder $container |
||
41 | * |
||
42 | * @return string |
||
43 | * |
||
44 | * @throws InvalidDefinitionException |
||
45 | */ |
||
46 | 2 | View Code Duplication | private function processCriteria( |
61 | |||
62 | /** |
||
63 | * @param ContainerBuilder $container |
||
64 | * @param string $contextId |
||
65 | * @param string $definitionName |
||
66 | * @param array $criteria |
||
67 | * |
||
68 | * @return Definition |
||
69 | */ |
||
70 | 2 | View Code Duplication | private function buildDefinition( |
94 | } |
||
95 |