alex-kalanis /
pohoda
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace kalanis\Pohoda\Document; |
||
| 6 | |||
| 7 | use kalanis\Pohoda\Common; |
||
| 8 | use kalanis\Pohoda\Type; |
||
| 9 | use kalanis\PohodaException; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @property Common\Dtos\AbstractSummaryDto $data |
||
| 13 | */ |
||
| 14 | abstract class AbstractSummary extends AbstractPart |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * {@inheritdoc} |
||
| 18 | */ |
||
| 19 | 11 | public function setData(Common\Dtos\AbstractDto $data): parent |
|
| 20 | { |
||
| 21 | // process home currency |
||
| 22 | 11 | if (isset($data->homeCurrency)) { |
|
| 23 | 3 | $homeCurrency = new Type\CurrencyHome($this->dependenciesFactory); |
|
| 24 | 3 | $homeCurrency |
|
| 25 | 3 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 26 | 3 | ->setResolveOptions($this->resolveOptions) |
|
| 27 | 3 | ->setData($data->homeCurrency); |
|
| 28 | 3 | $data->homeCurrency = $homeCurrency; |
|
| 29 | } |
||
| 30 | |||
| 31 | // process foreign currency |
||
| 32 | 11 | if (isset($data->foreignCurrency)) { |
|
| 33 | 6 | $foreignCurrency = new Type\CurrencyForeign($this->dependenciesFactory); |
|
| 34 | 6 | $foreignCurrency |
|
| 35 | 6 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 36 | 6 | ->setResolveOptions($this->resolveOptions) |
|
| 37 | 6 | ->setData($data->foreignCurrency); |
|
| 38 | 6 | $data->foreignCurrency = $foreignCurrency; |
|
| 39 | } |
||
| 40 | |||
| 41 | 11 | return parent::setData($data); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | 10 | public function getXML(): \SimpleXMLElement |
|
| 48 | { |
||
| 49 | 10 | if (is_null($this->namespace)) { |
|
| 50 | 1 | throw new PohodaException('Namespace not set.'); |
|
| 51 | } |
||
| 52 | |||
| 53 | 9 | if (is_null($this->nodePrefix)) { |
|
| 54 | 1 | throw new PohodaException('Node name prefix not set.'); |
|
| 55 | } |
||
| 56 | |||
| 57 | 8 | $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Summary', '', $this->namespace($this->namespace)); |
|
| 58 | |||
| 59 | 8 | $this->addElements($xml, $this->getDataElements(), $this->namespace); |
|
| 60 | |||
| 61 | 8 | return $xml; |
|
| 62 | } |
||
| 63 | } |
||
| 64 |