Passed
Push — master ( f4169b...5ce74f )
by Loban
02:35
created

SettingsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 11 3
1
<?php
2
3
namespace example\controllers;
4
5
use Yii;
6
use yii\web\Controller;
7
use example\models\SettingsForm;
8
9
class SettingsController extends Controller
10
{
11
    public function actionIndex()
12
    {
13
        $model = new SettingsForm();
14
15
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
0 ignored issues
show
Bug introduced by
It seems like Yii::app->request->post() can also be of type object; however, parameter $data of yii\base\Model::load() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        if ($model->load(/** @scrutinizer ignore-type */ Yii::$app->request->post()) && $model->save()) {
Loading history...
16
            Yii::$app->getSession()->setFlash('success', 'Settings successfully updated!');
17
            return $this->refresh();
18
        }
19
20
        return $this->render('settings', [
21
            'model' => $model,
22
        ]);
23
    }
24
}