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.
Test Setup Failed
Push — filters ( fb817b...44fc4f )
by
unknown
11:13
created

Meta::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %
Metric Value
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace app\modules\seo\models;
4
5
use app\backend\BackendModule;
6
use app\backend\components\BackendController;
7
use yii\data\ActiveDataProvider;
8
use yii\db\ActiveRecord;
9
10
/**
11
 * This is the model class for table "seo_meta".
12
 *
13
 * @property string $key
14
 * @property string $name
15
 * @property integer $content
16
 */
17
class Meta extends ActiveRecord
18
{
19
    /**
20
     * @inheritdoc
21
     */
22
    public static function tableName()
23
    {
24
        return '{{%seo_meta}}';
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 View Code Duplication
    public function rules()
31
    {
32
        return [
33
            [['key', 'name', 'content'], 'required'],
34
            [['key'], 'unique'],
35
            [['key', 'name', 'content'], 'string', 'max' => 255]
36
        ];
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function attributeLabels()
43
    {
44
        return [
45
            'key' => \Yii::t('app', 'Key'),
46
            'name' => \Yii::t('app', 'Name'),
47
            'content' => \Yii::t('app', 'Content'),
48
        ];
49
    }
50
51
    /**
52
     * Search meta tags
53
     * @param $params
54
     * @return ActiveDataProvider
55
     */
56
    public function search($params)
57
    {
58
        $this->load($params);
59
        $query = self::find();
60
        foreach ($this->attributes as $name => $value) {
61
            if (!empty($value)) {
62
                $query->andWhere("`$name` LIKE :$name", [":$name" => "%$value%"]);
63
            }
64
        }
65
        $dataProvider = new ActiveDataProvider(
66
            [
67
                'query' => $query,
68
                'pagination' => [
69
                    'pageSize' => 10,
70
                ],
71
            ]
72
        );
73
        return $dataProvider;
74
    }
75
76
    public static function registrationMeta()
77
    {
78
79
        if (
80
            \Yii::$app->request->isAjax === false &&
81
            \Yii::$app->controller->module instanceof BackendModule === false &&
82
            \Yii::$app->controller instanceof BackendController === false
83
        ) {
84
           $cacheName = \Yii::$app->getModule('seo')->cacheConfig['metaCache']['name'];
85
           $cacheExpire = \Yii::$app->getModule('seo')->cacheConfig['metaCache']['expire'];
86
87
           if (\Yii::$app->getCache()->get($cacheName)) {
88
               $metas = \Yii::$app->getCache()->get($cacheName);
89
           } else {
90
               $metas = Meta::find()->all();
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
91
               \Yii::$app->getCache()->set($cacheName, $metas, $cacheExpire);
92
           }
93
           foreach ($metas as $meta) {
94
               \Yii::$app->controller->getView()->registerMetaTag(
95
                   [
96
                       'name' => $meta->name,
97
                       'content' => $meta->content,
98
                   ],
99
                   $meta->key
100
               );
101
           }
102
       }
103
104
105
    }
106
}
107