AddressBook::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;
6
7
/**
8
 * @property AddressBook\AddressBookDto $data
9
 */
10
class AddressBook extends AbstractAgenda
11
{
12
    use Common\AddActionTypeTrait;
13
    use Common\AddParameterToHeaderTrait;
14
15 1
    public function getImportRoot(): string
16
    {
17 1
        return 'lAdb:addressbook';
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 6
    public function setData(Common\Dtos\AbstractDto $data): parent
24
    {
25
        // pass to header
26 6
        if (!empty($data->header)) {
27 6
            $header = new AddressBook\Header($this->dependenciesFactory);
28 6
            $header
29 6
                ->setDirectionalVariable($this->useOneDirectionalVariables)
30 6
                ->setResolveOptions($this->resolveOptions)
31 6
                ->setData($data->header);
32 6
            $data->header = $header;
33
        }
34
35 6
        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...
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 6
    public function getXML(): \SimpleXMLElement
42
    {
43 6
        $xml = $this->createXML()->addChild('adb:addressbook', '', $this->namespace('adb'));
44 6
        $xml->addAttribute('version', '2.0');
45
46 6
        $this->addElements($xml, $this->getDataElements(), 'adb');
47
48 6
        return $xml;
49
    }
50
51
    /**
52
     * @{inheritDoc}
53
     */
54 7
    protected function getDefaultDto(): Common\Dtos\AbstractDto
55
    {
56 7
        return new AddressBook\AddressBookDto();
57
    }
58
}
59