ConfigPrice::getSupportPrice()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
cc 3
nc 2
nop 0
crap 12
1
<?php
2
3
namespace hipanel\modules\server\models;
4
5
use hipanel\base\Model;
6
7
class ConfigPrice extends Model
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function rules()
13
    {
14
        return array_merge(parent::rules(), [
15
            [['location', 'currency', 'values', 'value', 'price', 'discounted_price', 'services'], 'string'],
16
            [['eur', 'usd'], 'string'],
17
        ]);
18
    }
19
20
    public function getFirstAvailable()
21
    {
22
        foreach (['eur', 'usd'] as $attribute) {
23
            if (!empty($this->values[$attribute])) {
0 ignored issues
show
Bug Best Practice introduced by
The property values does not exist on hipanel\modules\server\models\ConfigPrice. Since you implemented __get, consider adding a @property annotation.
Loading history...
24
                foreach ($this->values[$attribute] as $field => $value) {
25
                    $this->{$field} = $value;
26
                }
27
                break;
28
            }
29
        }
30
31
        return $this;
32
    }
33
34
    public function getSupportPrice(): ?string
35
    {
36
        if (!empty($this->services) && isset($this->services['monthly,support_time'])) {
0 ignored issues
show
Bug Best Practice introduced by
The property services does not exist on hipanel\modules\server\models\ConfigPrice. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
            return $this->services['monthly,support_time']['price'];
38
        }
39
40
        return null;
41
    }
42
}
43