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

Record   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 39
c 0
b 0
f 0
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 13 2
A getDefaultDto() 0 3 1
A getXML() 0 8 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