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 namespace Distilleries\Expendable\Http\Forms\Role; |
||
6 | class RoleForm extends FormValidator { |
||
7 | |||
8 | public static $rules = [ |
||
9 | 'libelle' => 'required', |
||
10 | 'initials' => 'required|unique:roles', |
||
11 | 'overide_permission' => 'integer' |
||
12 | ]; |
||
13 | |||
14 | public static $rules_update = [ |
||
15 | 'libelle' => 'required', |
||
16 | 'initials' => 'required|unique:roles,initials', |
||
17 | 'overide_permission' => 'integer' |
||
18 | ]; |
||
19 | |||
20 | public function buildForm() |
||
41 | |||
42 | View Code Duplication | protected function getUpdateRules() |
|
49 | } |