Passed
Push — master ( 221c35...fdb910 )
by Petr
02:59
created

Record::getXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
c 0
b 0
f 0
ccs 5
cts 5
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\PrintRequest;
6
7
use kalanis\Pohoda\AbstractAgenda;
8
use kalanis\Pohoda\Common;
9
10
/**
11
 * @property RecordDto $data
12
 */
13
class Record extends AbstractAgenda
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 3
    public function setData(Common\Dtos\AbstractDto $data): parent
19
    {
20 3
        if (!empty($data->filter)) {
21
            // process filter
22 3
            $filter = new Filter($this->dependenciesFactory);
23 3
            $filter
24 3
                ->setDirectionalVariable($this->useOneDirectionalVariables)
25 3
                ->setResolveOptions($this->resolveOptions)
26 3
                ->setData($data->filter);
27 3
            $data->filter = $filter;
28
        }
29
30 3
        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...
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 2
    public function getXML(): \SimpleXMLElement
37
    {
38 2
        $xml = $this->createXML()->addChild('prn:record', '', $this->namespace('prn'));
39 2
        $xml->addAttribute('agenda', strval($this->data->agenda));
40
41 2
        $this->addElements($xml, $this->getDataElements(), 'prn');
42
43 2
        return $xml;
44
    }
45
46
    /**
47
     * @{inheritDoc}
48
     */
49 3
    protected function getDefaultDto(): Common\Dtos\AbstractDto
50
    {
51 3
        return new RecordDto();
52
    }
53
}
54