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 |
||
| 17 | class Text extends AbstractField |
||
| 18 | { |
||
| 19 | use Orderable; |
||
| 20 | use Nullable; |
||
| 21 | use Tooltip; |
||
| 22 | use Clipboard; |
||
| 23 | use Inline; |
||
| 24 | use Translatable; |
||
| 25 | use Maskable; |
||
| 26 | use Placeholder; |
||
| 27 | use Maxlength; |
||
| 28 | use BelongsToArray; |
||
| 29 | |||
| 30 | 5 | View Code Duplication | public function value(Request $request) |
| 39 | |||
| 40 | 2 | View Code Duplication | public function getListView($model) |
| 52 | |||
| 53 | 1 | View Code Duplication | public function getEditFormView($model) |
| 54 | { |
||
| 55 | 1 | $template = $this->isReadonly() ? 'readonly' : 'edit'; |
|
| 56 | |||
| 57 | 1 | return view('jarboe::crud.fields.text.'. $template, [ |
|
| 58 | 1 | 'model' => $model, |
|
| 59 | 1 | 'field' => $this, |
|
| 60 | ]); |
||
| 61 | } |
||
| 62 | |||
| 63 | 1 | public function getCreateFormView() |
|
| 71 | |||
| 72 | public function getErrorsCount($errors): int |
||
| 80 | } |
||
| 81 |