Item   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 13
c 0
b 0
f 0
dl 0
loc 43
ccs 14
cts 14
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 10 2
A configureOptions() 0 8 1
A getXML() 0 7 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\StockTransfer;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common;
16
use Riesenia\Pohoda\Type\StockItem;
17
18
class Item extends AbstractAgenda
19
{
20
    /** @var string[] */
21
    protected array $elements = ['quantity', 'stockItem', 'note'];
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function setData(array $data): parent
27
    {
28
        // process stock item
29 1
        if (isset($data['stockItem'])) {
30 1
            $stockItem = new StockItem($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory);
31 1
            $stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['stockItem']);
32 1
            $data['stockItem'] = $stockItem;
33
        }
34
35 1
        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...
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function getXML(): \SimpleXMLElement
42
    {
43 1
        $xml = $this->createXML()->addChild('pre:prevodkaItem', '', $this->namespace('pre'));
44
45 1
        $this->addElements($xml, $this->elements, 'pre');
46
47 1
        return $xml;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
54
    {
55
        // available options
56 1
        $resolver->setDefined($this->elements);
57
58
        // validate / format options
59 1
        $resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float'));
60 1
        $resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90'));
61
    }
62
}
63