PrintRequest::getXML()   A
last analyzed

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;
6
7
class PrintRequest extends AbstractAgenda
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12 3
    public function setData(Common\Dtos\AbstractDto $data): parent
13
    {
14 3
        if (!empty($data->record)) {
15
            // process record
16 3
            $record = new PrintRequest\Record($this->dependenciesFactory);
17 3
            $record
18 3
                ->setDirectionalVariable($this->useOneDirectionalVariables)
19 3
                ->setResolveOptions($this->resolveOptions)
20 3
                ->setData($data->record);
21 3
            $data->record = $record;
22
        }
23
24 3
        if (!empty($data->printerSettings)) {
25
            // process printer settings
26 3
            $printerSettings = new PrintRequest\PrinterSettings($this->dependenciesFactory);
27 3
            $printerSettings
28 3
                ->setDirectionalVariable($this->useOneDirectionalVariables)
29 3
                ->setResolveOptions($this->resolveOptions)
30 3
                ->setData($data->printerSettings);
31 3
            $data->printerSettings = $printerSettings;
32
        }
33
34 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...
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function getXML(): \SimpleXMLElement
41
    {
42 2
        $xml = $this->createXML()->addChild('prn:print', '', $this->namespace('prn'));
43 2
        $xml->addAttribute('version', '1.0');
44
45 2
        $this->addElements($xml, $this->getDataElements(), 'prn');
46
47 2
        return $xml;
48
    }
49
50
    /**
51
     * @{inheritDoc}
52
     */
53 3
    protected function getDefaultDto(): Common\Dtos\AbstractDto
54
    {
55 3
        return new PrintRequest\PrintRequestDto();
56
    }
57
}
58