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.

ErrorLog::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use yii\behaviors\TimestampBehavior;
7
use yii\db\ActiveRecord;
8
use yii\db\Expression;
9
10
/**
11
 * Class ErrorMonitor
12
 * @package app\models
13
 *
14
 * This is the model class for table "error_log".
15
 *
16
 * @property integer $id
17
 * @property integer $url_id
18
 * @property integer $http_code
19
 * @property string $info
20
 * @property integer $timestamp
21
 * @property string $server_vars
22
 * @property string $request_vars
23
 */
24
class ErrorLog extends ActiveRecord
25
{
26
27
    public static function tableName()
28
    {
29
        return '{{%error_log}}';
30
    }
31
32
    public function behaviors()
33
    {
34
        return [
35
            [
36
                'class' => TimestampBehavior::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...
37
                'createdAtAttribute' => 'timestamp',
38
                'updatedAtAttribute' => null,
39
                'value' => new Expression('NOW()'),
40
            ],
41
        ];
42
    }
43
44 View Code Duplication
    public function rules()
45
    {
46
        return [
47
            [['id', 'url_id', 'http_code', 'timestamp'], 'integer'],
48
            [['info', 'server_vars', 'request_vars'], 'string']
49
        ];
50
    }
51
52
    public function scenarios()
53
    {
54
        return [
55
            'default' => ['id', 'url_id', 'http_code', 'info', 'server_vars', 'request_vars'],
56
            'search' => ['id', 'url_id', 'http_code', 'info', 'server_vars', 'request_vars'],
57
        ];
58
    }
59
60 View Code Duplication
    public function attributeLabels()
61
    {
62
        return [
63
            'id' => Yii::t('app', 'ID'),
64
            'url_id' => Yii::t('app', 'URL ID'),
65
            'http_code' => Yii::t('app', 'HTTP response code'),
66
            'info' => Yii::t('app', 'Information'),
67
            'timestamp' => Yii::t('app', 'Timestamp'),
68
            'server_vars' => Yii::t('app', 'Server variables'),
69
            'request_vars' => Yii::t('app', 'Request variables'),
70
        ];
71
    }
72
73
    public function getErrorUrl()
74
    {
75
        return $this->hasOne(ErrorUrl::className(), ['id' => 'url_id']);
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...
76
    }
77
78
    public function beforeSave($insert)
79
    {
80
        if (!parent::beforeSave($insert)) {
81
            return false;
82
        }
83
84
        $numberElementsToStore = Yii::$app->getModule('core')->numberElementsToStore - 1;
85
        $ids = static::find()->select('`id`')->where(['url_id' => $this->url_id])->orderBy('`id` DESC')
86
            ->offset($numberElementsToStore)->column();
87
        if (count($ids) > 0) {
88
            static::deleteAll(['in', '`id`', $ids]);
89
        }
90
        return true;
91
    }
92
}
93