Completed
Push — master ( 22cb37...1cdde8 )
by Dmitry
02:19
created

ActionDto   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 36
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 18 3
A rules() 0 8 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\commands\order;
4
5
use hiapi\validators\NestedModelValidator;
6
use yii\base\Model;
7
8
class ActionDto extends Model
9
{
10
    public $type;
11
12
    public $target;
13
14
    public $quantity;
15
16
    public function load($data, $formName = '')
17
    {
18
        if (isset($data['quantity'])) {
19
            $quantity = new QuantityDto();
20
            $quantity->load($data['quantity']);
21
22
            $data['quantity'] = $quantity;
23
        }
24
25
        if (isset($data['target'])) {
26
            $target = new TargetDto();
27
            $target->load($data['target']);
28
29
            $data['target'] = $target;
30
        }
31
32
        return $this->setAttributes($data);
33
    }
34
35
    public function rules()
36
    {
37
        return [
38
            [['type', 'target', 'quantity'], 'required'],
39
            [['target', 'quantity'], NestedModelValidator::class],
40
            [['type'], 'string']
41
        ];
42
    }
43
}
44