Supplier::getImportRoot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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
class Supplier extends AbstractAgenda
15
{
16 1
    public function getImportRoot(): string
17
    {
18 1
        return 'lst:supplier';
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function setData(array $data): parent
25
    {
26
        // process stockItem
27 2
        if (isset($data['stockItem'])) {
28 2
            $stockItem = new Supplier\StockItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
29 2
            $data['stockItem'] = $stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['stockItem']);
30
        }
31
32
        // process suppliers
33 2
        if (isset($data['suppliers']) && is_array($data['suppliers'])) {
34 2
            $data['suppliers'] = \array_map(function ($supplier) {
35 2
                $SupplierItem = new Supplier\SupplierItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
36 2
                return $SupplierItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($supplier['supplierItem']);
37 2
            }, $data['suppliers']);
38
        }
39
40 2
        return parent::setData($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::setData($data) returns the type Riesenia\Pohoda\AbstractAgenda which is incompatible with the type-hinted return parent.
Loading history...
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function getXML(): \SimpleXMLElement
47
    {
48 1
        $xml = $this->createXML()->addChild('sup:supplier', '', $this->namespace('sup'));
49 1
        $xml->addAttribute('version', '2.0');
50
51 1
        $this->addElements($xml, ['stockItem', 'suppliers'], 'sup');
52
53 1
        return $xml;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
60
    {
61
        // available options
62 1
        $resolver->setDefined(['stockItem', 'suppliers']);
63
    }
64
}
65