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\AbstractHeaderDto $data |
||
| 13 | */ |
||
| 14 | abstract class AbstractHeader extends AbstractPart |
||
| 15 | { |
||
| 16 | use Common\AddParameterTrait; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * {@inheritdoc} |
||
| 20 | */ |
||
| 21 | 54 | public function setData(Common\Dtos\AbstractDto $data): parent |
|
| 22 | { |
||
| 23 | // process partner identity |
||
| 24 | 54 | if (isset($data->partnerIdentity)) { |
|
| 25 | 43 | $parentIdentity = new Type\Address($this->dependenciesFactory); |
|
| 26 | 43 | $parentIdentity |
|
| 27 | 43 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 28 | 43 | ->setResolveOptions($this->resolveOptions) |
|
| 29 | 43 | ->setData($data->partnerIdentity); |
|
| 30 | 43 | $data->partnerIdentity = $parentIdentity; |
|
| 31 | } |
||
| 32 | |||
| 33 | // process my identity |
||
| 34 | 54 | if (isset($data->myIdentity)) { |
|
| 35 | 27 | $myIdentity = new Type\MyAddress($this->dependenciesFactory); |
|
| 36 | 27 | $myIdentity |
|
| 37 | 27 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 38 | 27 | ->setResolveOptions($this->resolveOptions) |
|
| 39 | 27 | ->setData($data->myIdentity); |
|
| 40 | 27 | $data->myIdentity = $myIdentity; |
|
| 41 | } |
||
| 42 | |||
| 43 | 54 | return parent::setData($data); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | 38 | public function getXML(): \SimpleXMLElement |
|
| 50 | { |
||
| 51 | 38 | if (is_null($this->namespace)) { |
|
| 52 | 1 | throw new PohodaException('Namespace not set.'); |
|
| 53 | } |
||
| 54 | |||
| 55 | 37 | if (is_null($this->nodePrefix)) { |
|
| 56 | 1 | throw new PohodaException('Node name prefix not set.'); |
|
| 57 | } |
||
| 58 | |||
| 59 | 36 | $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Header', '', $this->namespace($this->namespace)); |
|
| 60 | |||
| 61 | 36 | $this->addElements($xml, $this->getDataElements(), $this->namespace); |
|
| 62 | |||
| 63 | 36 | return $xml; |
|
| 64 | } |
||
| 65 | } |
||
| 66 |