alex-kalanis /
pohoda
| 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->dependenciesFactory); |
|
| 33 | 3 | $homeCurrency |
|
| 34 | 3 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 35 | 3 | ->setResolveOptions($this->resolveOptions) |
|
| 36 | 3 | ->setData($data['homeCurrency']); |
|
| 37 | 3 | $data['homeCurrency'] = $homeCurrency; |
|
| 38 | } |
||
| 39 | |||
| 40 | // process foreign currency |
||
| 41 | 11 | if (isset($data['foreignCurrency'])) { |
|
| 42 | 6 | $foreignCurrency = new Type\CurrencyForeign($this->dependenciesFactory); |
|
| 43 | 6 | $foreignCurrency |
|
| 44 | 6 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 45 | 6 | ->setResolveOptions($this->resolveOptions) |
|
| 46 | 6 | ->setData($data['foreignCurrency']); |
|
| 47 | 6 | $data['foreignCurrency'] = $foreignCurrency; |
|
| 48 | } |
||
| 49 | |||
| 50 | 11 | return parent::setData($data); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | 10 | public function getXML(): \SimpleXMLElement |
|
| 57 | { |
||
| 58 | 10 | if (is_null($this->namespace)) { |
|
| 59 | 1 | throw new \LogicException('Namespace not set.'); |
|
| 60 | } |
||
| 61 | |||
| 62 | 9 | if (is_null($this->nodePrefix)) { |
|
| 63 | 1 | throw new \LogicException('Node name prefix not set.'); |
|
| 64 | } |
||
| 65 | |||
| 66 | 8 | $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Summary', '', $this->namespace($this->namespace)); |
|
| 67 | |||
| 68 | 8 | $this->addElements($xml, $this->elements, $this->namespace); |
|
| 69 | |||
| 70 | 8 | return $xml; |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * {@inheritdoc} |
||
| 75 | */ |
||
| 76 | 8 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
| 77 | { |
||
| 78 | // available options |
||
| 79 | 8 | $resolver->setDefined($this->elements); |
|
| 80 | } |
||
| 81 | } |
||
| 82 |