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 |
||
| 24 | trait EventTriggers |
||
| 25 | { |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Triggers the before save event |
||
| 29 | * |
||
| 30 | * @param sql/Update|Sql/Insert $query |
||
|
|
|||
| 31 | * @param EntityInterface $entity |
||
| 32 | * @param array $data |
||
| 33 | * |
||
| 34 | * @return Save |
||
| 35 | */ |
||
| 36 | 4 | protected function triggerBeforeSave( |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Triggers the after save event |
||
| 51 | * |
||
| 52 | * @param Save $saveEvent |
||
| 53 | * @param EntityInterface $entity |
||
| 54 | * |
||
| 55 | * @return \League\Event\EventInterface|Save |
||
| 56 | */ |
||
| 57 | 4 | protected function triggerAfterSave( |
|
| 69 | |||
| 70 | /** |
||
| 71 | * Triggers the before delete event |
||
| 72 | * |
||
| 73 | * @param EntityInterface $entity |
||
| 74 | * |
||
| 75 | * @return \League\Event\EventInterface|Delete |
||
| 76 | */ |
||
| 77 | 2 | View Code Duplication | protected function triggerBeforeDelete(EntityInterface $entity) |
| 84 | |||
| 85 | /** |
||
| 86 | * Triggers the after delete event |
||
| 87 | * |
||
| 88 | * @param EntityInterface $entity |
||
| 89 | * |
||
| 90 | * @return \League\Event\EventInterface|Delete |
||
| 91 | */ |
||
| 92 | 2 | View Code Duplication | protected function triggerAfterDelete(EntityInterface $entity) |
| 99 | |||
| 100 | abstract public function getEntityClassName(); |
||
| 101 | } |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.