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 |
||
8 | final class PostInsertObjectsEvent extends Event |
||
9 | { |
||
10 | /** |
||
11 | * @var PagerInterface |
||
12 | */ |
||
13 | private $pager; |
||
14 | |||
15 | /** |
||
16 | * @var ObjectPersisterInterface |
||
17 | */ |
||
18 | private $objectPersister; |
||
19 | |||
20 | /** |
||
21 | * @var object[] |
||
22 | */ |
||
23 | private $objects; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $options; |
||
29 | |||
30 | 11 | View Code Duplication | public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $objects, array $options) |
37 | |||
38 | /** |
||
39 | * @return PagerInterface |
||
40 | */ |
||
41 | 2 | public function getPager() |
|
45 | |||
46 | /** |
||
47 | * @return array |
||
48 | */ |
||
49 | 2 | public function getOptions() |
|
53 | |||
54 | /** |
||
55 | * @return ObjectPersisterInterface |
||
56 | */ |
||
57 | 2 | public function getObjectPersister() |
|
61 | |||
62 | /** |
||
63 | * @return object[] |
||
64 | */ |
||
65 | 2 | public function getObjects() |
|
69 | } |