Item   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 9 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->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
31 1
            $data['stockItem'] = $stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['stockItem']);
32
        }
33
34 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...
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function getXML(): \SimpleXMLElement
41
    {
42 1
        $xml = $this->createXML()->addChild('pre:prevodkaItem', '', $this->namespace('pre'));
43
44 1
        $this->addElements($xml, $this->elements, 'pre');
45
46 1
        return $xml;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
53
    {
54
        // available options
55 1
        $resolver->setDefined($this->elements);
56
57
        // validate / format options
58 1
        $resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float'));
59 1
        $resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90'));
60
    }
61
}
62