StockItem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 39
c 0
b 0
f 0
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultDto() 0 3 1
A setData() 0 14 3
A getXML() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda\Stock;
6
7
use kalanis\Pohoda\AbstractAgenda;
8
use kalanis\Pohoda\Common;
9
10
/**
11
 * @property StockItemDto $data
12
 */
13
class StockItem extends AbstractAgenda
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 1
    public function setData(Common\Dtos\AbstractDto $data): parent
19
    {
20
        // process stockPriceItem
21 1
        if (!empty($data->stockPriceItem) && is_array($data->stockPriceItem)) {
22 1
            $data->stockPriceItem = \array_map(function (PriceDto $stockPriceItem) {
23 1
                $price = new Price($this->dependenciesFactory);
24 1
                $price->setDirectionalVariable($this->useOneDirectionalVariables)
25 1
                    ->setResolveOptions($this->resolveOptions)
26 1
                    ->setData($stockPriceItem);
27 1
                return $price;
28 1
            }, $data->stockPriceItem);
29
        }
30
31 1
        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...
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function getXML(): \SimpleXMLElement
38
    {
39 1
        $xml = $this->createXML()->addChild('stk:stockItem', '', $this->namespace('stk'));
40
41 1
        $this->addElements($xml, $this->getDataElements(), 'stk');
42
43 1
        return $xml;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    protected function getDefaultDto(): Common\Dtos\AbstractDto
50
    {
51 1
        return new StockItemDto();
52
    }
53
}
54