| Conditions | 4 |
| Paths | 1 |
| Total Lines | 73 |
| 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 |
||
| 75 | public function actions() |
||
| 76 | { |
||
| 77 | return [ |
||
| 78 | 'set-orientation' => [ |
||
| 79 | 'class' => OrientationAction::class, |
||
| 80 | 'allowedRoutes' => [ |
||
| 81 | '@bill/index', |
||
| 82 | ], |
||
| 83 | ], |
||
| 84 | 'index' => [ |
||
| 85 | 'class' => IndexAction::class, |
||
| 86 | 'data' => function ($action) { |
||
|
|
|||
| 87 | list($billTypes, $billGroupLabels) = $this->getTypesAndGroups(); |
||
| 88 | |||
| 89 | return compact('billTypes', 'billGroupLabels'); |
||
| 90 | }, |
||
| 91 | ], |
||
| 92 | 'view' => [ |
||
| 93 | 'class' => ViewAction::class, |
||
| 94 | ], |
||
| 95 | 'validate-form' => [ |
||
| 96 | 'class' => ValidateFormAction::class, |
||
| 97 | ], |
||
| 98 | 'create' => [ |
||
| 99 | 'class' => SmartCreateAction::class, |
||
| 100 | 'data' => function ($action) { |
||
| 101 | list($billTypes, $billGroupLabels) = $this->getTypesAndGroups(); |
||
| 102 | |||
| 103 | return compact('billTypes', 'billGroupLabels'); |
||
| 104 | }, |
||
| 105 | 'success' => Yii::t('hipanel:finance', 'Payment was created successfully'), |
||
| 106 | ], |
||
| 107 | 'update' => [ |
||
| 108 | 'class' => SmartUpdateAction::class, |
||
| 109 | 'success' => Yii::t('hipanel:finance', 'Payment was updated successfully'), |
||
| 110 | 'data' => function ($action) { |
||
| 111 | list($billTypes, $billGroupLabels) = $this->getTypesAndGroups(); |
||
| 112 | |||
| 113 | return compact('billTypes', 'billGroupLabels'); |
||
| 114 | }, |
||
| 115 | ], |
||
| 116 | 'copy' => [ |
||
| 117 | 'class' => SmartUpdateAction::class, |
||
| 118 | 'scenario' => 'create', |
||
| 119 | 'data' => function ($action, $data) { |
||
| 120 | foreach ($data['models'] as $model) { |
||
| 121 | /** @var Bill $model */ |
||
| 122 | $model->prepareToCopy(); |
||
| 123 | } |
||
| 124 | |||
| 125 | list($billTypes, $billGroupLabels) = $this->getTypesAndGroups(); |
||
| 126 | |||
| 127 | return compact('billTypes', 'billGroupLabels'); |
||
| 128 | }, |
||
| 129 | ], |
||
| 130 | 'delete' => [ |
||
| 131 | 'class' => SmartPerformAction::class, |
||
| 132 | 'success' => Yii::t('hipanel:finance', 'Payment was deleted successfully'), |
||
| 133 | ], |
||
| 134 | 'requisites' => [ |
||
| 135 | 'class' => RedirectAction::class, |
||
| 136 | 'url' => function ($action) { |
||
| 137 | $identity = Yii::$app->user->identity; |
||
| 138 | $seller = $identity->type === $identity::TYPE_RESELLER ? $identity->username : $identity->seller; |
||
| 139 | if ($seller === 'bullet') { |
||
| 140 | $seller = 'dsr'; |
||
| 141 | } |
||
| 142 | |||
| 143 | return array_merge(ContactController::getSearchUrl(['client' => $seller]), ['representation' => 'requisites']); |
||
| 144 | }, |
||
| 145 | ], |
||
| 146 | ]; |
||
| 147 | } |
||
| 148 | |||
| 192 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.