PrintRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 21
dl 0
loc 49
c 0
b 0
f 0
ccs 23
cts 23
cp 1
rs 10

3 Methods

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