PrintRequest::setData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of riesenia/pohoda package.
5
 *
6
 * Licensed under the MIT License
7
 * (c) RIESENIA.com
8
 */
9
10
declare(strict_types=1);
11
12
namespace Riesenia\Pohoda;
13
14
use Riesenia\Pohoda\PrintRequest\PrinterSettings;
15
use Riesenia\Pohoda\PrintRequest\Record;
16
17
class PrintRequest extends AbstractAgenda
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 3
    public function setData(array $data): parent
23
    {
24
        // process record
25 3
        $record = new Record($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
26 3
        $data['record'] = $record->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['record']);
27
28
        // process printer settings
29 3
        $printerSettings = new PrinterSettings($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
30 3
        $data['printerSettings'] = $printerSettings->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['printerSettings']);
31
32 3
        return parent::setData($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::setData($data) returns the type Riesenia\Pohoda\AbstractAgenda which is incompatible with the type-hinted return parent.
Loading history...
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 2
    public function getXML(): \SimpleXMLElement
39
    {
40 2
        $xml = $this->createXML()->addChild('prn:print', '', $this->namespace('prn'));
41 2
        $xml->addAttribute('version', '1.0');
42
43 2
        $this->addElements($xml, ['record', 'printerSettings'], 'prn');
44
45 2
        return $xml;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
52
    {
53
        // available options
54 1
        $resolver->setDefined(['record', 'printerSettings']);
55
56 1
        $resolver->setRequired('record');
57 1
        $resolver->setRequired('printerSettings');
58
    }
59
}
60