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 PreInsertObjectsEvent 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 | 23 | View Code Duplication | public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $objects, array $options) |
| 47 | |||
| 48 | 13 | public function getPager(): PagerInterface |
|
| 52 | |||
| 53 | 1 | public function setPager(PagerInterface $pager) |
|
| 57 | |||
| 58 | 16 | public function getOptions(): array |
|
| 62 | |||
| 63 | 1 | public function setOptions(array $options) |
|
| 67 | |||
| 68 | 3 | public function getObjectPersister(): ObjectPersisterInterface |
|
| 72 | |||
| 73 | 1 | public function setObjectPersister(ObjectPersisterInterface $objectPersister) |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @return object[] |
||
| 80 | */ |
||
| 81 | 16 | public function getObjects() |
|
| 85 | |||
| 86 | /** |
||
| 87 | * @param object[] $objects |
||
| 88 | */ |
||
| 89 | 3 | public function setObjects($objects) |
|
| 93 | } |
||
| 94 |