MyAddress::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\MyAddressDto $data
12
 */
13
class MyAddress extends AbstractAgenda
14
{
15
    use Common\SetNamespaceTrait;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 28
    public function setData(Common\Dtos\AbstractDto $data): parent
21
    {
22
        // process address
23 28
        if (isset($data->address)) {
24 27
            $address = new AddressInternetType($this->dependenciesFactory);
25 27
            $address
26 27
                ->setDirectionalVariable($this->useOneDirectionalVariables)
27 27
                ->setResolveOptions($this->resolveOptions)
28 27
                ->setData($data->address);
29 27
            $data->address = $address;
30
        }
31
        // process establishment
32 28
        if (isset($data->establishment)) {
33 1
            $establishment = new EstablishmentType($this->dependenciesFactory);
34 1
            $establishment
35 1
                ->setDirectionalVariable($this->useOneDirectionalVariables)
36 1
                ->setResolveOptions($this->resolveOptions)
37 1
                ->setData($data->establishment);
38 1
            $data->establishment = $establishment;
39
        }
40
41 28
        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...
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 28
    protected function getDefaultDto(): Common\Dtos\AbstractDto
48
    {
49 28
        return new Dtos\MyAddressDto();
50
    }
51
}
52