GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SpamCheckerController::actionDelete()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace app\backend\controllers;
4
5
use app\backend\traits\BackendRedirect;
6
use app\models\SpamChecker;
7
use Yii;
8
use yii\filters\AccessControl;
9
use yii\web\Controller;
10
use yii\web\NotFoundHttpException;
11
12
class SpamCheckerController extends Controller
13
{
14
    use BackendRedirect;
15
    /**
16
     * @inheritdoc
17
     */
18 View Code Duplication
    public function behaviors()
19
    {
20
        return [
21
            'access' => [
22
                'class' => AccessControl::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
23
                'rules' => [
24
                    [
25
                        'allow' => true,
26
                        'roles' => ['setting manage'],
27
                    ],
28
                ],
29
            ],
30
        ];
31
    }
32
33
    public function actionIndex()
34
    {
35
        $searchModel = new SpamChecker;
36
        $params = Yii::$app->request->get();
37
        $dataProvider = $searchModel->search($params);
38
        return $this->render(
39
            'index',
40
            [
41
                'dataProvider' => $dataProvider,
42
                'searchModel' => $searchModel,
43
            ]
44
        );
45
    }
46
47
    public function actionEdit($id = null)
48
    {
49
        if ($id === null) {
50
            $model = new SpamChecker;
51
        } else {
52
            $model = SpamChecker::findOne($id);
53
        }
54
        if ($model === null) {
55
            throw new NotFoundHttpException;
56
        }
57
        $post = Yii::$app->request->post();
58
        if ($model->load($post) && $model->validate()) {
59 View Code Duplication
            if ($model->save()) {
60
                return $this->redirectUser($model->id);
61
            } else {
62
                Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot save data'));
63
            }
64
        }
65
        return $this->render('spam-checker-form', ['model' => $model]);
66
    }
67
68
    public function actionDelete($id)
69
    {
70
        $model = SpamChecker::findOne($id);
71
        if ($model === null) {
72
            throw new NotFoundHttpException;
73
        }
74
        if ($model->delete()) {
75
            Yii::$app->session->setFlash('info', Yii::t('app', 'Object removed'));
76
        } else {
77
            Yii::$app->session->setFlash('error', Yii::t('app', 'Object not removed'));
78
        }
79
        return $this->redirect(['index']);
80
    }
81
82
    public function actionDeleteAll()
83
    {
84
        $items = Yii::$app->request->post('items', []);
85
        if (empty($items) === false) {
86
            SpamChecker::deleteAll(['in', 'id', $items]);
87
        }
88
        $this->render(['index']);
0 ignored issues
show
Documentation introduced by
array('index') is of type array<integer,string,{"0":"string"}>, but the function expects a string.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
89
    }
90
91
}
92