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 OnExceptionEvent 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 \Exception |
||
| 32 | */ |
||
| 33 | private $exception; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var array |
||
| 37 | */ |
||
| 38 | private $options; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | private $objects; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var bool |
||
| 47 | */ |
||
| 48 | private $ignored = false; |
||
| 49 | |||
| 50 | 11 | View Code Duplication | public function __construct( |
| 63 | |||
| 64 | 2 | public function getPager(): PagerInterface |
|
| 68 | |||
| 69 | 2 | public function getOptions(): array |
|
| 73 | |||
| 74 | 2 | public function getObjectPersister(): ObjectPersisterInterface |
|
| 78 | |||
| 79 | 3 | public function getException(): \Exception |
|
| 83 | |||
| 84 | 1 | public function setException(\Exception $exception) |
|
| 88 | |||
| 89 | 4 | public function isIgnored(): bool |
|
| 93 | |||
| 94 | 2 | public function setIgnored(bool $ignored) |
|
| 98 | |||
| 99 | 1 | public function getObjects(): array |
|
| 103 | } |
||
| 104 |