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 |
||
18 | final class PostInsertObjectsEvent extends Event implements PersistEvent |
||
19 | { |
||
20 | /** |
||
21 | * @var PagerInterface |
||
22 | */ |
||
23 | private $pager; |
||
24 | |||
25 | /** |
||
26 | * @var ObjectPersisterInterface |
||
27 | */ |
||
28 | private $objectPersister; |
||
29 | |||
30 | /** |
||
31 | * @var object[] |
||
32 | */ |
||
33 | private $objects; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $options; |
||
39 | |||
40 | 20 | View Code Duplication | public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $objects, array $options) |
47 | |||
48 | 6 | public function getPager(): PagerInterface |
|
52 | |||
53 | 2 | public function getOptions(): array |
|
57 | |||
58 | 2 | public function getObjectPersister(): ObjectPersisterInterface |
|
62 | |||
63 | /** |
||
64 | * @return object[] |
||
65 | */ |
||
66 | 2 | public function getObjects(): array |
|
70 | } |
||
71 |