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 |
||
12 | class ExistsAndDeletePermission |
||
13 | { |
||
14 | private $exists; |
||
15 | private $attached; |
||
16 | private $delete; |
||
17 | |||
18 | /** |
||
19 | * ExistsAndDeletePermission constructor. |
||
20 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
21 | */ |
||
22 | 3 | public function __construct() |
|
28 | |||
29 | /** |
||
30 | * @param Permission $permission |
||
31 | * @return bool |
||
32 | * @throws PermissionDoesNotExistsException |
||
33 | * @throws PermissionIsAttachedException |
||
34 | */ |
||
35 | 3 | View Code Duplication | public function make(Permission $permission): bool |
51 | } |
||
52 |