SupplierItem   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 23
c 1
b 0
f 0
dl 0
loc 47
ccs 22
cts 22
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 18 1
A getXML() 0 13 2
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\Supplier;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common\OptionsResolver;
16
17
class SupplierItem extends AbstractAgenda
18
{
19
    /** @var string[] */
20
    protected array $refElements = ['refAd', 'currency', 'deliveryPeriod'];
21
22
    /** @var string[] */
23
    protected array $elements = ['default', 'refAd', 'orderCode', 'orderName', 'purchasingPrice', 'currency', 'rate', 'payVAT', 'ean', 'printEAN', 'unitEAN', 'unitCoefEAN', 'deliveryTime', 'deliveryPeriod', 'minQuantity', 'unit', 'note'];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function getXML(): \SimpleXMLElement
29
    {
30 1
        $xml = $this->createXML()->addChild('sup:supplierItem', '', $this->namespace('sup'));
31
32
        // handle default
33 1
        if ($this->data['default']) {
34 1
            $xml->addAttribute('default', strval($this->data['default']));
35 1
            unset($this->data['default']);
36
        }
37
38 1
        $this->addElements($xml, $this->elements, 'sup');
39
40 1
        return $xml;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    protected function configureOptions(OptionsResolver $resolver): void
47
    {
48
        // available options
49 1
        $resolver->setDefined($this->elements);
50
51 1
        $resolver->setNormalizer('default', $this->normalizerFactory->getClosure('bool'));
52 1
        $resolver->setNormalizer('orderCode', $this->normalizerFactory->getClosure('string64'));
53 1
        $resolver->setNormalizer('orderName', $this->normalizerFactory->getClosure('string90'));
54 1
        $resolver->setNormalizer('purchasingPrice', $this->normalizerFactory->getClosure('number'));
55 1
        $resolver->setNormalizer('rate', $this->normalizerFactory->getClosure('float'));
56 1
        $resolver->setNormalizer('payVAT', $this->normalizerFactory->getClosure('bool'));
57 1
        $resolver->setNormalizer('ean', $this->normalizerFactory->getClosure('string20'));
58 1
        $resolver->setNormalizer('printEAN', $this->normalizerFactory->getClosure('bool'));
59 1
        $resolver->setNormalizer('unitEAN', $this->normalizerFactory->getClosure('string10'));
60 1
        $resolver->setNormalizer('unitCoefEAN', $this->normalizerFactory->getClosure('float'));
61 1
        $resolver->setNormalizer('deliveryTime', $this->normalizerFactory->getClosure('int'));
62 1
        $resolver->setNormalizer('minQuantity', $this->normalizerFactory->getClosure('float'));
63 1
        $resolver->setNormalizer('unit', $this->normalizerFactory->getClosure('string10'));
64
    }
65
}
66