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

CalculateValueCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 26
ccs 0
cts 12
cp 0
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 13 3
A rules() 0 7 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\commands\order;
4
5
use hiapi\commands\BaseCommand;
6
use hiapi\validators\NestedModelValidator;
7
8
class CalculateValueCommand extends BaseCommand
9
{
10
    public $items;
11
12
    public function load($data, $formName = '')
13
    {
14
        if (isset($data['items'])) {
15
            $items = [];
16
            foreach ($data['items'] as $item) {
17
                $items[] = $action = new ActionDto();
18
                $action->load($item);
19
            }
20
            $data['items'] = $items;
21
        }
22
23
        return $this->setAttributes($data);
24
    }
25
26
    public function rules()
27
    {
28
        return [
29
            ['items', 'required'],
30
            ['items', 'each', 'rule' => [NestedModelValidator::class]],
31
        ];
32
    }
33
}
34