Request::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
/**
12
 * @see    http://hiqdev.com/hipanel-module-hosting
13
 * @license http://hiqdev.com/hipanel-module-hosting/license
14
 * @copyright Copyright (c) 2015 HiQDev
15
 */
16
17
namespace hipanel\modules\hosting\models;
18
19
use hipanel\base\Model;
20
use hipanel\base\ModelTrait;
21
use Yii;
22
23
class Request extends Model
24
{
25
    use ModelTrait;
26
27
    /** {@inheritdoc} */
28
    public function rules()
29
    {
30
        return [
31
            [['id', 'object_id', 'service_id', 'client_id', 'account_id', 'server_id'], 'integer'],
32
            [['realm', 'service', 'client', 'account', 'server', 'type_ids'], 'safe'],
33
            [['child', 'parent', 'error_code', 'error_detailed'], 'string'],
34
            [['type', 'type_label', 'state', 'state_label', 'action', 'object_class', 'classes', 'class_label'], 'safe'],
35
            [['parent_id', 'child_id', 'tries_left', 'pid', 'time_lag'], 'integer'],
36
            [['object_name'], 'safe'],
37
            [['time', 'create_time', 'update_time'], 'date'],
38
            [['id'], 'integer', 'on' => ['delete']],
39
        ];
40
    }
41
42
    /** {@inheritdoc} */
43
    public function attributeLabels()
44
    {
45
        return $this->mergeAttributeLabels([
46
            'object_name' => Yii::t('hipanel:hosting', 'Object Name'),
47
            'object' => Yii::t('hipanel:hosting', 'Object'),
48
            'classes' => Yii::t('hipanel:hosting', 'Object'),
49
            'type_ids' => Yii::t('hipanel', 'Types'),
50
            'time' => Yii::t('hipanel:hosting', 'Scheduled time'),
51
            'pid' => Yii::t('hipanel:hosting', 'PID'),
52
        ]);
53
    }
54
55
    public function getObject(): string
56
    {
57
        return sprintf('%s %s', $this->server, empty($this->object_name) ? $this->class_label : $this->object_name);
0 ignored issues
show
Documentation introduced by
The property server does not exist on object<hipanel\modules\hosting\models\Request>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property object_name does not exist on object<hipanel\modules\hosting\models\Request>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property class_label does not exist on object<hipanel\modules\hosting\models\Request>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
58
    }
59
}
60