Item::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 19
ccs 16
cts 16
cp 1
rs 9.7666
cc 1
nc 1
nop 1
crap 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\Invoice;
13
14
use Riesenia\Pohoda\Common;
15
use Riesenia\Pohoda\Document\AbstractItem;
16
use Riesenia\Pohoda\Type\RecyclingContrib;
17
18
class Item extends AbstractItem
19
{
20
    /** @var string[] */
21
    protected array $refElements = ['typeServiceMOSS', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract'];
22
23
    /** @var string[] */
24
    protected array $elements = ['text', 'quantity', 'unit', 'coefficient', 'payVAT', 'rateVAT', 'percentVAT', 'discountPercentage', 'homeCurrency', 'foreignCurrency', 'typeServiceMOSS', 'note', 'code', 'guarantee', 'guaranteeType', 'stockItem', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract', 'expirationDate', 'PDP', 'recyclingContrib'];
25
26
    /**
27
     * @inheritdoc
28
     */
29 3
    public function setData(array $data): parent
30
    {
31 3
        if (isset($data['recyclingContrib'])) {
32 1
            $recyclingContrib = new RecyclingContrib($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory);
33 1
            $recyclingContrib->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['recyclingContrib']);
34 1
            $data['recyclingContrib'] = $recyclingContrib;
35
        }
36
37 3
        return parent::setData($data);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
44
    {
45 1
        parent::configureOptions($resolver);
46
47
        // validate / format options
48 1
        $resolver->setNormalizer('text', $this->normalizerFactory->getClosure('string90'));
49 1
        $resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float'));
50 1
        $resolver->setNormalizer('unit', $this->normalizerFactory->getClosure('string10'));
51 1
        $resolver->setNormalizer('coefficient', $this->normalizerFactory->getClosure('float'));
52 1
        $resolver->setNormalizer('payVAT', $this->normalizerFactory->getClosure('bool'));
53 1
        $resolver->setAllowedValues('rateVAT', ['none', 'high', 'low', 'third', 'historyHigh', 'historyLow', 'historyThird']);
54 1
        $resolver->setNormalizer('percentVAT', $this->normalizerFactory->getClosure('float'));
55 1
        $resolver->setNormalizer('discountPercentage', $this->normalizerFactory->getClosure('float'));
56 1
        $resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90'));
57 1
        $resolver->setNormalizer('code', $this->normalizerFactory->getClosure('string64'));
58 1
        $resolver->setNormalizer('guarantee', $this->normalizerFactory->getClosure('int'));
59 1
        $resolver->setAllowedValues('guaranteeType', ['none', 'hour', 'day', 'month', 'year', 'life']);
60 1
        $resolver->setNormalizer('expirationDate', $this->normalizerFactory->getClosure('date'));
61 1
        $resolver->setNormalizer('PDP', $this->normalizerFactory->getClosure('bool'));
62
    }
63
}
64