| Conditions | 5 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 9.0581 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 6 | public function actionIndex() |
|
| 15 | { |
||
| 16 | 6 | $model = new SettingsForm(); |
|
| 17 | |||
| 18 | 6 | if (Yii::$app->request->isPost) { |
|
| 19 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
||
| 20 | Yii::$app->settings->load($model->getAttributes()); |
||
| 21 | Yii::$app->session->setFlash('success', Yii::t('app.messages', 'Saved successfully')); |
||
| 22 | return $this->refresh(); |
||
| 23 | } |
||
| 24 | if (Yii::$app->request->isAjax) { |
||
| 25 | return $this->asJson($this->collectErrors($model)); |
||
|
|
|||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | 6 | $model->setAttributes(Yii::$app->settings->all()); |
|
| 30 | |||
| 31 | 6 | return $this->render('index', ['model' => $model]); |
|
| 32 | } |
||
| 33 | } |
||
| 34 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: