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 AbstractHeader extends AbstractPart |
||
18 | { |
||
19 | use Common\AddParameterTrait; |
||
20 | |||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | 54 | public function setData(array $data): parent |
|
25 | { |
||
26 | // process partner identity |
||
27 | 54 | if (isset($data['partnerIdentity'])) { |
|
28 | 43 | $parentIdentity = new Type\Address($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
29 | 43 | $data['partnerIdentity'] = $parentIdentity->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['partnerIdentity']); |
|
30 | } |
||
31 | |||
32 | // process my identity |
||
33 | 54 | if (isset($data['myIdentity'])) { |
|
34 | 27 | $myIdentity = new Type\MyAddress($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
35 | 27 | $data['myIdentity'] = $myIdentity->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['myIdentity']); |
|
36 | } |
||
37 | |||
38 | 54 | return parent::setData($data); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 38 | public function getXML(): \SimpleXMLElement |
|
45 | { |
||
46 | 38 | if (is_null($this->namespace)) { |
|
47 | 1 | throw new \LogicException('Namespace not set.'); |
|
48 | } |
||
49 | |||
50 | 37 | if (is_null($this->nodePrefix)) { |
|
51 | 1 | throw new \LogicException('Node name prefix not set.'); |
|
52 | } |
||
53 | |||
54 | 36 | $xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Header', '', $this->namespace($this->namespace)); |
|
55 | |||
56 | 36 | $this->addElements($xml, \array_merge($this->elements, ['parameters']), $this->namespace); |
|
57 | |||
58 | 36 | return $xml; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 8 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
65 | { |
||
66 | // available options |
||
67 | 8 | $resolver->setDefined($this->elements); |
|
68 | } |
||
69 | } |
||
70 |