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 |
||
| 14 | class Textarea extends AbstractField |
||
| 15 | { |
||
| 16 | use Orderable; |
||
| 17 | use Nullable; |
||
| 18 | use Tooltip; |
||
| 19 | use Clipboard; |
||
| 20 | use Inline; |
||
| 21 | use Translatable; |
||
| 22 | use Placeholder; |
||
| 23 | |||
| 24 | protected $rows = 3; |
||
| 25 | protected $expandable = false; |
||
| 26 | protected $resizable = false; |
||
| 27 | |||
| 28 | public function rows(int $rows) |
||
| 34 | |||
| 35 | public function getRowsNum() |
||
| 39 | |||
| 40 | public function expandable(bool $expandable = true) |
||
| 46 | |||
| 47 | public function isExpandable() |
||
| 51 | |||
| 52 | public function resizable(bool $resizable = true) |
||
| 58 | |||
| 59 | public function isResizable() |
||
| 63 | |||
| 64 | View Code Duplication | public function value(Request $request) |
|
| 73 | |||
| 74 | 1 | public function getListValue($model) |
|
| 86 | |||
| 87 | 1 | View Code Duplication | public function getEditFormValue($model) |
| 96 | |||
| 97 | 1 | public function getCreateFormValue() |
|
| 103 | } |
||
| 104 |