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 |
||
| 26 | class UpdaterRepository extends RepositoryUpdater implements UserUpdater |
||
| 27 | { |
||
| 28 | public function __construct(UserInterface $model) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Add a new user. |
||
| 35 | * |
||
| 36 | * @param array $info |
||
| 37 | * |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | View Code Duplication | public function create(array $info) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Soft deletes a user and empties the email. |
||
| 58 | * |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function delete() |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Updates the users settings, validates the fields. |
||
| 75 | * |
||
| 76 | * @param array $info |
||
| 77 | * |
||
| 78 | * @return Eloquent\Model |
||
| 79 | */ |
||
| 80 | public function update(array $attributes = [], array $options = []) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Update user messages setting. |
||
| 93 | * |
||
| 94 | * @param array $input |
||
| 95 | */ |
||
| 96 | View Code Duplication | public function updateMessagesSettings(array $input) |
|
| 107 | } |
||
| 108 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..