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 |
||
21 | class User extends AggregateRoot implements EventSourcedAggregateRoot |
||
22 | { |
||
23 | private $id; |
||
24 | |||
25 | private function __construct(UserId $id) |
||
29 | |||
30 | public static function signUp(UserId $id) : self |
||
37 | |||
38 | protected function applyUserSignedUp(UserSignedUp $event) : void |
||
41 | |||
42 | View Code Duplication | public static function reconstitute(EventStream $stream) : EventSourcedAggregateRoot |
|
52 | |||
53 | public function id() : UserId |
||
57 | |||
58 | public function __toString() : string |
||
62 | } |
||
63 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.