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 |
||
13 | class GroupCategoryRepository implements NotifynderGroupCategoryDB |
||
14 | { |
||
15 | /** |
||
16 | * @var NotificationGroup |
||
17 | */ |
||
18 | protected $notificationGroup; |
||
19 | |||
20 | /** |
||
21 | * @var NotificationCategory |
||
22 | */ |
||
23 | protected $notificationCategory; |
||
24 | |||
25 | /** |
||
26 | * @param NotifynderCategory $notificationCategory |
||
27 | * @param NotificationGroup $notificationGroup |
||
28 | */ |
||
29 | public function __construct(NotifynderCategory $notificationCategory, |
||
35 | |||
36 | /** |
||
37 | * Add a category in a group. |
||
38 | * |
||
39 | * @param $groupId |
||
40 | * @param $categoryId |
||
41 | * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|static |
||
42 | */ |
||
43 | public function addCategoryToGroupById($groupId, $categoryId) |
||
50 | |||
51 | /** |
||
52 | * Add a category in a group |
||
53 | * by names given. |
||
54 | * |
||
55 | * @param $groupName |
||
56 | * @param $categoryName |
||
57 | * @return mixed |
||
58 | */ |
||
59 | View Code Duplication | public function addCategoryToGroupByName($groupName, $categoryName) |
|
69 | |||
70 | /** |
||
71 | * Add multiple categories by them names |
||
72 | * to a group. |
||
73 | * |
||
74 | * @param $groupName |
||
75 | * @param $names |
||
76 | * @return mixed |
||
77 | */ |
||
78 | View Code Duplication | public function addMultipleCategoriesToGroup($groupName, array $names) |
|
90 | } |
||
91 |
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..