Address::getDefaultDto()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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