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 | /** |
||
18 | * @property array{ |
||
19 | * homeCurrency?: Type\CurrencyHome, |
||
20 | * foreignCurrency?: Type\CurrencyForeign, |
||
21 | * } $data |
||
22 | */ |
||
23 | abstract class AbstractSummary extends AbstractPart |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | 11 | public function setData(array $data): parent |
|
29 | { |
||
30 | // process home currency |
||
31 | 11 | if (isset($data['homeCurrency'])) { |
|
32 | 3 | $homeCurrency = new Type\CurrencyHome($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
|
33 | 3 | $homeCurrency->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['homeCurrency']); |
|
34 | 3 | $data['homeCurrency'] = $homeCurrency; |
|
35 | } |
||
36 | |||
37 | // process foreign currency |
||
38 | 11 | if (isset($data['foreignCurrency'])) { |
|
39 | 6 | $foreignCurrency = new Type\CurrencyForeign($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
|
40 | 6 | $foreignCurrency->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['foreignCurrency']); |
|
41 | 6 | $data['foreignCurrency'] = $foreignCurrency; |
|
42 | } |
||
43 | |||
44 | 11 | return parent::setData($data); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | 10 | public function getXML(): \SimpleXMLElement |
|
51 | { |
||
52 | 10 | if (is_null($this->namespace)) { |
|
53 | 1 | throw new \LogicException('Namespace not set.'); |
|
54 | } |
||
55 | |||
56 | 9 | if (is_null($this->nodePrefix)) { |
|
57 | 1 | throw new \LogicException('Node name prefix not set.'); |
|
58 | } |
||
59 | |||
60 | 8 | $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Summary', '', $this->namespace($this->namespace)); |
|
61 | |||
62 | 8 | $this->addElements($xml, $this->elements, $this->namespace); |
|
63 | |||
64 | 8 | return $xml; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 8 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
71 | { |
||
72 | // available options |
||
73 | 8 | $resolver->setDefined($this->elements); |
|
74 | } |
||
75 | } |
||
76 |