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; |
||
13 | |||
14 | use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding; |
||
15 | |||
16 | class StockTransfer extends AbstractAgenda |
||
17 | { |
||
18 | use Common\AddParameterToHeaderTrait; |
||
19 | |||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | 4 | public function setData(array $data): parent |
|
24 | { |
||
25 | // pass to header |
||
26 | 4 | $header = new StockTransfer\Header($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
27 | 4 | $data = ['header' => $header->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data)]; |
|
28 | |||
29 | 4 | return parent::setData($data); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
30 | } |
||
31 | |||
32 | 1 | public function getImportRoot(): string |
|
33 | { |
||
34 | 1 | return 'lst:prevodka'; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Add item. |
||
39 | * |
||
40 | * @param array<string,mixed> $data |
||
41 | * |
||
42 | * @return $this |
||
43 | */ |
||
44 | 1 | public function addItem(array $data): self |
|
45 | { |
||
46 | 1 | if (!isset($this->data['prevodkaDetail']) |
|
47 | 1 | || !( |
|
48 | 1 | is_array($this->data['prevodkaDetail']) |
|
49 | 1 | || (is_object($this->data['prevodkaDetail']) && is_a($this->data['prevodkaDetail'], \ArrayAccess::class)) |
|
50 | 1 | ) |
|
51 | ) { |
||
52 | 1 | $this->data['prevodkaDetail'] = []; |
|
53 | } |
||
54 | |||
55 | 1 | $prevodkaDetail = new StockTransfer\Item($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
56 | 1 | $this->data['prevodkaDetail'][] = $prevodkaDetail->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data); |
|
57 | |||
58 | 1 | return $this; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 3 | public function getXML(): \SimpleXMLElement |
|
65 | { |
||
66 | 3 | $xml = $this->createXML()->addChild('pre:prevodka', '', $this->namespace('pre')); |
|
67 | 3 | $xml->addAttribute('version', '2.0'); |
|
68 | |||
69 | 3 | $this->addElements($xml, ['header', 'prevodkaDetail'], 'pre'); |
|
70 | |||
71 | 3 | return $xml; |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | 1 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
78 | { |
||
79 | // available options |
||
80 | 1 | $resolver->setDefined(['header']); |
|
81 | } |
||
82 | } |
||
83 |