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 |
||
17 | class PersisterRegistry implements ContainerAwareInterface |
||
18 | { |
||
19 | use ContainerAwareTrait; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $persisters = []; |
||
25 | |||
26 | /** |
||
27 | * @param array $persisters |
||
28 | */ |
||
29 | public function __construct(array $persisters) |
||
33 | |||
34 | /** |
||
35 | * Gets the persister for an index and type. |
||
36 | * |
||
37 | * @param string $index |
||
38 | * @param string $type |
||
39 | * |
||
40 | * @return ObjectPersisterInterface |
||
41 | * |
||
42 | * @throws \InvalidArgumentException if no persister was registered for the index and type |
||
43 | */ |
||
44 | View Code Duplication | public function getPersister($index, $type) |
|
52 | } |
||
53 |