StockItem::getXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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