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 ServerResource 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
|
|
View Code Duplication |
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
|
|
|
public function isTypeCorrect() |
64
|
|
|
{ |
65
|
|
|
return isset($this->getAvailableTypes()[$this->type]); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.