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 PreInsertObjectsEvent extends Event implements PersistEvent |
||
|
|||
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 | 22 | View Code Duplication | public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $objects, array $options) |
37 | |||
38 | /** |
||
39 | * @return PagerInterface |
||
40 | */ |
||
41 | 12 | public function getPager() |
|
45 | |||
46 | /** |
||
47 | * @param PagerInterface $pager |
||
48 | */ |
||
49 | 1 | public function setPager($pager) |
|
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | 15 | public function getOptions() |
|
61 | |||
62 | /** |
||
63 | * @param array $options |
||
64 | */ |
||
65 | 1 | public function setOptions(array $options) |
|
69 | |||
70 | /** |
||
71 | * @return ObjectPersisterInterface |
||
72 | */ |
||
73 | 3 | public function getObjectPersister() |
|
77 | |||
78 | /** |
||
79 | * @param ObjectPersisterInterface $objectPersister |
||
80 | */ |
||
81 | 1 | public function setObjectPersister(ObjectPersisterInterface $objectPersister) |
|
85 | |||
86 | /** |
||
87 | * @return object[] |
||
88 | */ |
||
89 | 15 | public function getObjects() |
|
93 | |||
94 | /** |
||
95 | * @param object[] $objects |
||
96 | */ |
||
97 | 3 | public function setObjects($objects) |
|
101 | } |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.