Completed
Push — master ( 0e490c...4b4ef3 )
by Dmitry
11:06
created

ServerTariffManager::insert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
ccs 0
cts 11
cp 0
rs 9.7998
cc 2
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\logic;
12
13
use hipanel\modules\finance\forms\ServerTariffForm;
14
use hipanel\modules\finance\forms\VdsTariffForm;
15
use hipanel\modules\finance\models\Tariff;
16
use hiqdev\hiart\ResponseErrorException;
17
use Yii;
18
use yii\web\NotFoundHttpException;
19
use yii\web\UnprocessableEntityHttpException;
20
21
class ServerTariffManager extends AbstractTariffManager
22
{
23
    public $type = 'server';
24
25
    /**
26
     * @var VdsTariffForm
27
     */
28
    public $form;
29
30
    public function init()
31
    {
32
        if (!Yii::getAlias('@server', true)) {
33
            throw new NotFoundHttpException('Server module is missing');
34
        }
35
36
        parent::init();
37
    }
38
39
    protected function getFormOptions()
40
    {
41
        return array_merge([
42
            'class' => ServerTariffForm::class,
43
        ], parent::getFormOptions());
44
    }
45
}
46