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 namespace Bedard\Shop\Controllers; |
||
| 9 | View Code Duplication | class Carts extends Controller |
|
| 10 | { |
||
| 11 | public $bodyClass = 'compact-container'; |
||
| 12 | |||
| 13 | public $formConfig = 'config_form.yaml'; |
||
| 14 | |||
| 15 | public $implement = [ |
||
| 16 | 'Backend.Behaviors.FormController', |
||
| 17 | 'Backend.Behaviors.ListController', |
||
| 18 | 'Owl.Behaviors.ListDelete.Behavior', |
||
| 19 | ]; |
||
| 20 | |||
| 21 | public $listConfig = 'config_list.yaml'; |
||
| 22 | |||
| 23 | public $registerPermissions = [ |
||
| 24 | 'bedard.shop.carts.manage', |
||
| 25 | ]; |
||
| 26 | |||
| 27 | public function __construct() |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Extend the list query. |
||
| 36 | * |
||
| 37 | * @param \Illuminate\Database\Query\Builder $query |
||
| 38 | * @return \Illuminate\Database\Query\Builder |
||
| 39 | */ |
||
| 40 | public function listExtendQuery($query) |
||
| 44 | } |
||
| 45 |