Completed
Push — master ( 030ae6...89eb04 )
by Dmitry
04:29
created

DomainResource::getServiceTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * Finance module for HiPanel
5
 *
6
 * @link      https://github.com/hiqdev/hipanel-module-finance
7
 * @package   hipanel-module-finance
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\modules\finance\models;
13
14
use Yii;
15
16
/**
17
 * Class DomainResource
18
 * @package hipanel\modules\finance\models
19
 */
20
class DomainResource extends Resource
21
{
22
    public static function index()
23
    {
24
        return 'resources';
25
    }
26
27
    public static function type()
28
    {
29
        return 'resource';
30
    }
31
32
    const TYPE_DOMAIN_REGISTRATION = 'dregistration';
33
    const TYPE_DOMAIN_TRANSFER = 'dtransfer';
34
    const TYPE_DOMAIN_RENEWAL = 'drenewal';
35
    const TYPE_DOMAIN_DELETE_AGP = 'ddelete_agp';
36
    const TYPE_DOMAIN_RESTORE_EXPIRED = 'drestore_expired';
37
    const TYPE_DOMAIN_RESTORE_DELETED = 'drestore_deleted';
38
39
    const TYPE_PREMIUM_DNS = 'premium_dns';
40
41
    /**
42
     * @return array
43
     */
44
    public function getAvailableTypes()
45
    {
46
        return [
47
            static::TYPE_DOMAIN_REGISTRATION => Yii::t('hipanel/finance/tariff', 'Registration'),
48
            static::TYPE_DOMAIN_TRANSFER => Yii::t('hipanel/finance/tariff', 'Transfer'),
49
            static::TYPE_DOMAIN_RENEWAL => Yii::t('hipanel/finance/tariff', 'Renewal'),
50
            static::TYPE_DOMAIN_DELETE_AGP => Yii::t('hipanel/finance/tariff', 'Delete in AGP'),
51
            static::TYPE_DOMAIN_RESTORE_EXPIRED => Yii::t('hipanel/finance/tariff', 'Restoring expired'),
52
            static::TYPE_DOMAIN_RESTORE_DELETED => Yii::t('hipanel/finance/tariff', 'Restoring deleted'),
53
        ];
54
    }
55
56
    public function getServiceTypes()
57
    {
58
        return [
59
            static::TYPE_PREMIUM_DNS => Yii::t('hipanel/finance/tariff', 'Premium DNS')
60
        ];
61
    }
62
63
64
    public function isTypeCorrect()
65
    {
66
        return isset($this->getAvailableTypes()[$this->type]);
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<hipanel\modules\f...\models\DomainResource>. 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...
67
    }
68
}
69