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.

SliderHandler::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use devgroup\TagDependencyHelper\ActiveRecordHelper;
6
use Yii;
7
8
/**
9
 * This is the model class for table "{{%slider_handler}}".
10
 *
11
 * @property integer $id
12
 * @property string $name
13
 * @property string $slider_widget
14
 * @property string $slider_edit_view_file
15
 */
16
class SliderHandler extends \yii\db\ActiveRecord
17
{
18
    private static $identity_map = [];
19
20
    use \app\traits\FindById;
21
22
    public function behaviors()
23
    {
24
        return [
25
            [
26
                'class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::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...
27
            ],
28
        ];
29
    }
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function tableName()
34
    {
35
        return '{{%slider_handler}}';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function rules()
42
    {
43
        return [
44
            [['name', 'slider_widget', 'slider_edit_view_file', 'edit_model'], 'string', 'max' => 255]
45
        ];
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function attributeLabels()
52
    {
53
        return [
54
            'id' => Yii::t('app', 'ID'),
55
            'name' => Yii::t('app', 'Name'),
56
            'slider_widget' => Yii::t('app', 'Slider Widget'),
57
            'slider_edit_view_file' => Yii::t('app', 'Slider Edit View File'),
58
        ];
59
    }
60
    /**
61
    * Returns model using indentity map and cache
62
    * @param string $id
63
    * @return SliderHandler|null
64
    */
65 View Code Duplication
    public static function findBySliderId($id)
66
    {
67
        if (!isset(SliderHandler::$identity_map[$id])) {
68
            $cacheKey = SliderHandler::tableName().":$id";
69
            if (false === $model = Yii::$app->cache->get($cacheKey)) {
70
                $model = SliderHandler::findById($id);
71
72
                if (null !== $model) {
73
                    Yii::$app->cache->set(
74
                        $cacheKey,
75
                        $model,
76
                        86400,
77
                        new \yii\caching\TagDependency([
78
                            'tags' => [
79
                                ActiveRecordHelper::getObjectTag($model, $model->id)
80
                            ]
81
                        ])
82
                    );
83
                }
84
            }
85
            static::$identity_map[$id] = $model;
86
        }
87
88
        return static::$identity_map[$id];
89
    }
90
91
}
92