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 |
||
5 | class SearchDocumentsRequest extends Request |
||
6 | { |
||
7 | public $warnings = []; |
||
8 | |||
9 | /** |
||
10 | * Sanitize/standardize input. |
||
11 | */ |
||
12 | public function sanitize() |
||
47 | |||
48 | /** |
||
49 | * Determine if the user is authorized to make this request. |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | public function authorize() |
||
57 | |||
58 | /** |
||
59 | * Get the validation rules that apply to the request. |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function rules() |
||
67 | } |
||
68 |