Address   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 18
dl 0
loc 38
c 0
b 0
f 0
ccs 18
cts 18
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultDto() 0 3 1
A setData() 0 23 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda\Type;
6
7
use kalanis\Pohoda\AbstractAgenda;
8
use kalanis\Pohoda\Common;
9
10
/**
11
 * @property Dtos\AddressDto $data
12
 */
13
class Address extends AbstractAgenda
14
{
15
    use Common\SetNamespaceTrait;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 55
    public function setData(Common\Dtos\AbstractDto $data): parent
21
    {
22
        // process address
23 55
        if (isset($data->address)) {
24 22
            $address = new AddressType($this->dependenciesFactory);
25 22
            $address
26 22
                ->setDirectionalVariable($this->useOneDirectionalVariables)
27 22
                ->setResolveOptions($this->resolveOptions)
28 22
                ->setData($data->address);
29 22
            $data->address = $address;
30
        }
31
32
        // process shipping address
33 55
        if (isset($data->shipToAddress)) {
34 1
            $shipTo = new ShipToAddressType($this->dependenciesFactory);
35 1
            $shipTo
36 1
                ->setDirectionalVariable($this->useOneDirectionalVariables)
37 1
                ->setResolveOptions($this->resolveOptions)
38 1
                ->setData($data->shipToAddress);
39 1
            $data->shipToAddress = $shipTo;
40
        }
41
42 55
        return parent::setData($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::setData($data) returns the type kalanis\Pohoda\AbstractAgenda which is incompatible with the type-hinted return parent.
Loading history...
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 55
    protected function getDefaultDto(): Common\Dtos\AbstractDto
49
    {
50 55
        return new Dtos\AddressDto();
51
    }
52
}
53