| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 6.5971 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | 1 | public function actionIndex() |
|
| 14 | { |
||
| 15 | 1 | $model = new SettingsForm(); |
|
| 16 | |||
| 17 | 1 | if (Yii::$app->request->isPost) { |
|
| 18 | Yii::$app->response->format = 'json'; |
||
| 19 | |||
| 20 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
||
| 21 | Yii::$app->settings->load($model->getAttributes()); |
||
| 22 | |||
| 23 | Yii::$app->session->setFlash('success', Yii::t('app', 'Saved successfully')); |
||
| 24 | return $this->refresh(); |
||
| 25 | } |
||
| 26 | return $this->asJsonModelErrors($model); |
||
|
|
|||
| 27 | } |
||
| 28 | |||
| 29 | 1 | $model->setAttributes(Yii::$app->settings->all()); |
|
| 30 | |||
| 31 | 1 | 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: