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.

PropertyHandler::init()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.7333
c 0
b 0
f 0
cc 4
nc 4
nop 0
1
<?php
2
3
namespace app\backend\actions;
4
5
use app\models\BaseObject;
6
use app\models\Property;
7
use app\properties\PropertyHandlers;
8
use yii;
9
use yii\base\Action;
10
11
class PropertyHandler extends Action
12
{
13
    public $modelName = null;
14
    public $objectId = null;
15
16
    /**
17
     * @throws yii\web\ServerErrorHttpException
18
     */
19 View Code Duplication
    public function init()
20
    {
21
        parent::init();
22
        if (null === $this->modelName) {
23
            throw new yii\web\ServerErrorHttpException('Model name should be set in controller actions');
24
        }
25
26
        if (!is_subclass_of($this->modelName, '\yii\db\ActiveRecord')) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
27
            throw new yii\web\ServerErrorHttpException('Model class does not exists');
28
        }
29
30
        $this->objectId = BaseObject::getForClass($this->modelName);
31
        if (null === $this->objectId) {
32
            throw new yii\web\ServerErrorHttpException('Object does not exists for model.');
33
        }
34
    }
35
36
    /**
37
     * @param null $property_id
38
     * @param null $handler_action
39
     * @param null $model_id
40
     * @return mixed
41
     */
42
    public function run($property_id = null, $handler_action = null, $model_id = null)
43
    {
44
        if (null === $handler_action
45
            || null === $property_id
46
            || null === $model_id)
47
        {
48
            return '';
49
        }
50
51
        $property = Property::findById($property_id);
52
        if (null === $property) {
53
            return '';
54
        }
55
56
        $actionParams = [
57
            'model_name' => $this->modelName,
58
            'model_id' => $model_id,
59
            'object_id' => $this->objectId,
60
            'property' => $property,
61
        ];
62
        $propertyHandler = PropertyHandlers::createHandler($property->handler);
0 ignored issues
show
Bug introduced by
The property handler does not seem to exist. Did you mean handlerAdditionalParams?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
63
        return $propertyHandler->runAction($handler_action, $actionParams);
64
    }
65
}
66