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 |
||
| 15 | class Textarea extends AbstractField |
||
| 16 | { |
||
| 17 | use Orderable; |
||
| 18 | use Nullable; |
||
| 19 | use Tooltip; |
||
| 20 | use Clipboard; |
||
| 21 | use Inline; |
||
| 22 | use Translatable; |
||
| 23 | use Placeholder; |
||
| 24 | use Maxlength; |
||
| 25 | |||
| 26 | protected $rows = 3; |
||
| 27 | protected $expandable = false; |
||
| 28 | protected $resizable = false; |
||
| 29 | |||
| 30 | 1 | public function rows(int $rows) |
|
| 36 | |||
| 37 | 2 | public function getRowsNum() |
|
| 41 | |||
| 42 | 1 | public function expandable(bool $expandable = true) |
|
| 48 | |||
| 49 | 2 | public function isExpandable() |
|
| 53 | |||
| 54 | 1 | public function resizable(bool $resizable = true) |
|
| 60 | |||
| 61 | 2 | public function isResizable() |
|
| 65 | |||
| 66 | 3 | View Code Duplication | public function value(Request $request) |
| 75 | |||
| 76 | 2 | View Code Duplication | public function getListView($model) |
| 88 | |||
| 89 | 1 | public function getEditFormView($model) |
|
| 98 | |||
| 99 | 1 | public function getCreateFormView() |
|
| 105 | } |
||
| 106 |