We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 13 | public function __construct() |
||
| 14 | { |
||
| 15 | parent::__construct(); |
||
| 16 | |||
| 17 | $this->crud->setModel("Backpack\MenuCRUD\app\Models\MenuItem"); |
||
| 18 | $this->crud->setRoute(config('backpack.base.route_prefix').'/menu-item'); |
||
| 19 | $this->crud->setEntityNameStrings('menu item', 'menu items'); |
||
| 20 | |||
| 21 | $this->crud->allowAccess('reorder'); |
||
| 22 | $this->crud->enableReorder('name', 2); |
||
| 23 | |||
| 24 | $this->crud->addColumn([ |
||
| 25 | 'name' => 'name', |
||
| 26 | 'label' => 'Label', |
||
| 27 | ]); |
||
| 28 | $this->crud->addColumn([ |
||
| 29 | 'label' => 'Parent', |
||
| 30 | 'type' => 'select', |
||
| 31 | 'name' => 'parent_id', |
||
| 32 | 'entity' => 'parent', |
||
| 33 | 'attribute' => 'name', |
||
| 34 | 'model' => "\Backpack\MenuCRUD\app\Models\MenuItem", |
||
| 35 | ]); |
||
| 36 | |||
| 37 | $this->crud->addColumn([ |
||
| 38 | 'label' => 'Menu Label', |
||
| 39 | 'type' => 'select', |
||
| 40 | 'name' => 'menu_id', |
||
| 41 | 'entity' => 'menu', |
||
| 42 | 'attribute' => 'name', |
||
| 43 | 'model' => "\Backpack\MenuCRUD\app\Models\Menu", |
||
| 44 | ]); |
||
| 45 | |||
| 46 | $this->crud->addField([ |
||
| 47 | 'name' => 'name', |
||
| 48 | 'label' => 'Label', |
||
| 49 | ]); |
||
| 50 | $this->crud->addField([ |
||
| 51 | 'label' => 'Parent', |
||
| 52 | 'type' => 'select', |
||
| 53 | 'name' => 'parent_id', |
||
| 54 | 'entity' => 'parent', |
||
| 55 | 'attribute' => 'name', |
||
| 56 | 'model' => "\Backpack\MenuCRUD\app\Models\MenuItem", |
||
| 57 | ]); |
||
| 58 | $this->crud->addField([ |
||
| 59 | 'label' => 'Menu', |
||
| 60 | 'type' => 'select', |
||
| 61 | 'name' => 'menu_id', |
||
| 62 | 'entity' => 'parent', |
||
| 63 | 'attribute' => 'name', |
||
| 64 | 'model' => "\Backpack\MenuCRUD\app\Models\Menu", |
||
| 65 | ]); |
||
| 66 | $this->crud->addField([ |
||
| 67 | 'name' => 'type', |
||
| 68 | 'label' => 'Type', |
||
| 69 | 'type' => 'page_or_link', |
||
| 70 | 'page_model' => '\Backpack\PageManager\app\Models\Page', |
||
| 71 | ]); |
||
| 72 | } |
||
| 73 | |||
| 84 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.