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 PostAsyncInsertObjectsEvent 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 int |
||
| 22 | */ |
||
| 23 | private $objectsCount; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string|null |
||
| 27 | */ |
||
| 28 | private $errorMessage; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private $options; |
||
| 34 | |||
| 35 | 6 | View Code Duplication | public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, $objectsCount, $errorMessage, array $options) |
| 43 | |||
| 44 | /** |
||
| 45 | * @return PagerInterface |
||
| 46 | */ |
||
| 47 | 1 | public function getPager() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | 1 | public function getOptions() |
|
| 59 | |||
| 60 | /** |
||
| 61 | * @return ObjectPersisterInterface |
||
| 62 | */ |
||
| 63 | 1 | public function getObjectPersister() |
|
| 67 | |||
| 68 | /** |
||
| 69 | * @return null|string |
||
| 70 | */ |
||
| 71 | 1 | public function getErrorMessage() |
|
| 75 | |||
| 76 | /** |
||
| 77 | * @return int |
||
| 78 | */ |
||
| 79 | 1 | public function getObjectsCount() |
|
| 83 | } |