Supplier   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 24
dl 0
loc 56
c 0
b 0
f 0
ccs 27
cts 27
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getImportRoot() 0 3 1
A setData() 0 25 4
A getXML() 0 8 1
A getDefaultDto() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda;
6
7
/**
8
 * @property Supplier\SupplierDto $data
9
 */
10
class Supplier extends AbstractAgenda
11
{
12 1
    public function getImportRoot(): string
13
    {
14 1
        return 'lst:supplier';
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 2
    public function setData(Common\Dtos\AbstractDto $data): parent
21
    {
22
        // process stockItem
23 2
        if (isset($data->stockItem)) {
24 2
            $stockItem = new Supplier\StockItem($this->dependenciesFactory);
25 2
            $stockItem
26 2
                ->setDirectionalVariable($this->useOneDirectionalVariables)
27 2
                ->setResolveOptions($this->resolveOptions)
28 2
                ->setData($data->stockItem);
29 2
            $data->stockItem = $stockItem;
30
        }
31
32
        // process suppliers
33 2
        if (!empty($data->suppliers) && is_array($data->suppliers)) {
34 2
            $data->suppliers = \array_map(function (Supplier\SupplierItemDto $item) {
35 2
                $supplierItem = new Supplier\SupplierItem($this->dependenciesFactory);
36 2
                $supplierItem
37 2
                    ->setDirectionalVariable($this->useOneDirectionalVariables)
38 2
                    ->setResolveOptions($this->resolveOptions)
39 2
                    ->setData($item);
40 2
                return $supplierItem;
41 2
            }, $data->suppliers);
42
        }
43
44 2
        return parent::setData($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::setData($data) returns the type kalanis\Pohoda\AbstractAgenda which is incompatible with the type-hinted return parent.
Loading history...
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function getXML(): \SimpleXMLElement
51
    {
52 1
        $xml = $this->createXML()->addChild('sup:supplier', '', $this->namespace('sup'));
53 1
        $xml->addAttribute('version', '2.0');
54
55 1
        $this->addElements($xml, $this->getDataElements(), 'sup');
56
57 1
        return $xml;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 2
    protected function getDefaultDto(): Common\Dtos\AbstractDto
64
    {
65 2
        return new Supplier\SupplierDto();
66
    }
67
}
68