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.

ConfigConfigurationModel::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\backend\models;
4
5
use app;
6
use app\modules\config\models\BaseConfigurationModel;
7
use Yii;
8
9
/**
10
 * Class ConfigConfigurationModel represents configuration model for retrieving user input
11
 * in backend configuration subsystem.
12
 *
13
 * @package app\backend\models
14
 */
15
class ConfigConfigurationModel extends BaseConfigurationModel
16
{
17
    /**
18
     * @var boolean Should we show backend floating panel on bottom?
19
     */
20
    public $floatingPanelBottom = false;
21
22
    public $wysiwygUploadDir = '/upload/images';
23
24
    public $backendEditGrids = [];
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function rules()
30
    {
31
        return [
32
            [
33
                [
34
                    'floatingPanelBottom',
35
                ],
36
                'boolean',
37
            ],
38
            [
39
                [
40
                    'floatingPanelBottom',
41
                ],
42
                'filter',
43
                'filter' => 'boolval',
44
            ],
45
            [
46
                [
47
                    'wysiwygUploadDir',
48
                ],
49
                'required',
50
            ],
51
            [
52
                ['backendEditGrids'], 'each', 'rule' => ['each', 'rule' => ['string']],
53
            ],
54
        ];
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public function attributeLabels()
61
    {
62
        return [
63
            'floatingPanelBottom' => Yii::t('app', 'Display backend floating panel on bottom'),
64
        ];
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function defaultValues()
71
    {
72
        /** @var app\backend\BackendModule $module */
73
        $module = Yii::$app->modules['backend'];
74
75
        $attributes = array_keys($this->getAttributes());
76
        foreach ($attributes as $attribute) {
77
            if ($module->hasProperty($attribute)) {
78
                $this->{$attribute} = $module->{$attribute};
79
            }
80
        }
81
        $this->floatingPanelBottom = false;
82
        if (is_array($module->floatingPanel)) {
83
            if (isset($module->floatingPanel['bottom'])) {
84
                $this->floatingPanelBottom = $module->floatingPanel['bottom'];
85
            }
86
        }
87
    }
88
89
    /**
90
     * Returns array of module configuration that should be stored in application config.
91
     * Array should be ready to merge in app config.
92
     * Used both for web only.
93
     *
94
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array<strin...rray<string,boolean>>>>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
95
     */
96
    public function webApplicationAttributes()
97
    {
98
        $attributes = $this->getAttributes(null, ['floatingPanelBottom']);
99
        $attributes['floatingPanel'] = [
100
            'bottom' => $this->floatingPanelBottom,
101
        ];
102
103
        return [
104
            'modules' => [
105
                'backend' => $attributes,
106
            ],
107
        ];
108
    }
109
110
    /**
111
     * Returns array of module configuration that should be stored in application config.
112
     * Array should be ready to merge in app config.
113
     * Used both for console only.
114
     *
115
     * @return array
116
     */
117
    public function consoleApplicationAttributes()
118
    {
119
        return [];
120
    }
121
122
    /**
123
     * Returns array of module configuration that should be stored in application config.
124
     * Array should be ready to merge in app config.
125
     * Used both for web and console.
126
     *
127
     * @return array
128
     */
129
    public function commonApplicationAttributes()
130
    {
131
        return [];
132
    }
133
134
    /**
135
     * Returns array of key=>values for configuration.
136
     *
137
     * @return mixed
138
     */
139
    public function keyValueAttributes()
140
    {
141
        return [];
142
    }
143
144
    /**
145
     * Returns array of aliases that should be set in common config
146
     * @return array
147
     */
148
    public function aliases()
149
    {
150
        return [];
151
    }
152
153
    public function getAllBackendEditGrids()
154
    {
155
        $grids = [];
156
        foreach (Yii::$app->getModules(true) as $module) {
157
            /** @var app\backend\BackendModule $module */
158
            $moduleGrids = $module->hasMethod('getBackendGrids') ? $module->getBackendGrids() : null;
0 ignored issues
show
Documentation Bug introduced by
The method getBackendGrids does not exist on object<app\backend\BackendModule>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
159
            if (!empty($moduleGrids)) {
160
                $grids[$module->id] = $moduleGrids;
161
                if (!isset($this->backendEditGrids[$module->id])) {
162
                    $this->backendEditGrids[$module->id] = [];
163
                }
164
                foreach ($moduleGrids as $grid) {
165
                    if (!isset($this->backendEditGrids[$module->id][$grid['key']])) {
166
                        $this->backendEditGrids[$module->id][$grid['key']] = $grid['defaultValue'];
167
                    }
168
                }
169
            }
170
        }
171
        return $grids;
172
    }
173
}
174