AbstractSummary::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
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\Document;
13
14
use Riesenia\Pohoda\Common;
15
use Riesenia\Pohoda\Type;
16
17
abstract class AbstractSummary extends AbstractPart
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 11
    public function setData(array $data): parent
23
    {
24
        // process home currency
25 11
        if (isset($data['homeCurrency'])) {
26 3
            $homeCurrency = new Type\CurrencyHome($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
27 3
            $data['homeCurrency'] = $homeCurrency->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['homeCurrency']);
28
        }
29
30
        // process foreign currency
31 11
        if (isset($data['foreignCurrency'])) {
32 6
            $foreignCurrency = new Type\CurrencyForeign($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
33 6
            $data['foreignCurrency'] = $foreignCurrency->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['foreignCurrency']);
34
        }
35
36 11
        return parent::setData($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::setData($data) returns the type Riesenia\Pohoda\Document\AbstractPart which is incompatible with the type-hinted return parent.
Loading history...
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 10
    public function getXML(): \SimpleXMLElement
43
    {
44 10
        if (is_null($this->namespace)) {
45 1
            throw new \LogicException('Namespace not set.');
46
        }
47
48 9
        if (is_null($this->nodePrefix)) {
49 1
            throw new \LogicException('Node name prefix not set.');
50
        }
51
52 8
        $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Summary', '', $this->namespace($this->namespace));
53
54 8
        $this->addElements($xml, $this->elements, $this->namespace);
55
56 8
        return $xml;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 8
    protected function configureOptions(Common\OptionsResolver $resolver): void
63
    {
64
        // available options
65 8
        $resolver->setDefined($this->elements);
66
    }
67
}
68