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 | View Code Duplication | class Events extends ArrayCollection implements FromArrayInterface |
|
| 19 | { |
||
| 20 | /** |
||
| 21 | * @param Event $event |
||
| 22 | * |
||
| 23 | * @return $this |
||
| 24 | */ |
||
| 25 | public function addEvent(Event $event) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param Event $event |
||
| 34 | */ |
||
| 35 | public function removeEvent(Event $event) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | public static function fromArray(array $data) |
||
| 53 | } |
||
| 54 |