| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 17 | public function actions() |
||
| 18 | { |
||
| 19 | return [ |
||
| 20 | 'index' => [ |
||
| 21 | 'class' => IndexAction::class, |
||
| 22 | 'data' => function () { |
||
| 23 | return [ |
||
| 24 | 'types' => $this->getTypes(), |
||
| 25 | ]; |
||
| 26 | } |
||
| 27 | ], |
||
| 28 | 'view' => [ |
||
| 29 | 'on beforePerform' => function (Event $event) { |
||
| 30 | /** @var \hipanel\actions\SearchAction $action */ |
||
| 31 | $action = $event->sender; |
||
| 32 | $dataProvider = $action->getDataProvider(); |
||
| 33 | $dataProvider->query->joinWith(['bindings']); |
||
| 34 | $dataProvider->query->andWhere(['with_bindings' => 1]); |
||
| 35 | }, |
||
| 36 | 'class' => ViewAction::class, |
||
| 37 | ], |
||
| 38 | 'create' => [ |
||
| 39 | 'class' => SmartCreateAction::class, |
||
| 40 | 'success' => Yii::t('hipanel:server:hub', 'Switch was created'), |
||
| 41 | 'data' => function () { |
||
| 42 | return [ |
||
| 43 | 'types' => $this->getTypes(), |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | ], |
||
| 47 | 'update' => [ |
||
| 48 | 'class' => SmartUpdateAction::class, |
||
| 49 | 'success' => Yii::t('hipanel:server:hub', 'Switch was updated'), |
||
| 50 | 'data' => function () { |
||
| 51 | return [ |
||
| 52 | 'types' => $this->getTypes(), |
||
| 53 | ]; |
||
| 54 | } |
||
| 55 | ], |
||
| 56 | 'options' => [ |
||
| 57 | 'class' => SmartUpdateAction::class, |
||
| 58 | 'success' => Yii::t('hipanel:server:hub', 'Options was updated'), |
||
| 59 | 'data' => function () { |
||
| 60 | return [ |
||
| 61 | 'snmpOptions' => $this->getSnmpOptions(), |
||
| 62 | 'digitalCapacityOptions' => $this->getDigitalCapacityOptions(), |
||
| 63 | 'nicMediaOptions' => $this->getNicMediaOptions(), |
||
| 64 | ]; |
||
| 65 | } |
||
| 66 | ], |
||
| 67 | ]; |
||
| 68 | } |
||
| 69 | |||
| 103 | } |