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 |
||
| 10 | class Date extends AbstractField |
||
| 11 | { |
||
| 12 | use Orderable; |
||
| 13 | use Nullable; |
||
| 14 | use Inline; |
||
| 15 | use Placeholder; |
||
| 16 | |||
| 17 | protected $format = 'YYYY-MM-DD'; |
||
| 18 | protected $months = 1; |
||
| 19 | |||
| 20 | 3 | View Code Duplication | public function default($value) |
| 31 | |||
| 32 | 1 | public function format(string $momentJsFormat) |
|
| 38 | |||
| 39 | 2 | public function getDateFormat() |
|
| 43 | |||
| 44 | 2 | public function months(int $months) |
|
| 50 | |||
| 51 | 2 | public function getMonths() |
|
| 55 | |||
| 56 | public function getListValue($model) |
||
| 63 | |||
| 64 | public function getEditFormValue($model) |
||
| 73 | |||
| 74 | public function getCreateFormValue() |
||
| 80 | } |
||
| 81 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.