CurrencyHome::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 3
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\Type;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common;
16
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding;
17
18
class CurrencyHome extends AbstractAgenda
19
{
20
    use Common\SetNamespaceTrait;
21
22
    /** @var string[] */
23
    protected array $refElements = ['round'];
24
25
    /** @var string[] */
26
    protected array $elements = ['priceNone', 'price3', 'price3VAT', 'price3Sum', 'priceLow', 'priceLowVAT', 'priceLowVatRate', 'priceLowSum', 'priceHigh', 'priceHighVAT', 'priceHighVatRate', 'priceHighSum', 'round'];
27
28 4
    public function __construct(
29
        Common\NamespacesPaths $namespacesPaths,
30
        SanitizeEncoding $sanitizeEncoding,
31
        Common\OptionsResolver\Normalizers\NormalizerFactory $normalizerFactory = new Common\OptionsResolver\Normalizers\NormalizerFactory(),
32
    ) {
33
        // init attributes
34 4
        $this->elementsAttributesMapper = [
35 4
            'priceLowVatRate' => new Common\ElementAttributes('priceLowVAT', 'rate'),
36 4
            'priceHighVatRate' => new Common\ElementAttributes('priceHighVAT', 'rate'),
37 4
        ];
38
39 4
        parent::__construct($namespacesPaths, $sanitizeEncoding, $normalizerFactory);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
46
    {
47
        // available options
48 1
        $resolver->setDefined($this->elements);
49
50
        // validate / format options
51 1
        $resolver->setNormalizer('priceNone', $this->normalizerFactory->getClosure('float'));
52 1
        $resolver->setNormalizer('price3', $this->normalizerFactory->getClosure('float'));
53 1
        $resolver->setNormalizer('price3VAT', $this->normalizerFactory->getClosure('float'));
54 1
        $resolver->setNormalizer('price3Sum', $this->normalizerFactory->getClosure('float'));
55 1
        $resolver->setNormalizer('priceLow', $this->normalizerFactory->getClosure('float'));
56 1
        $resolver->setNormalizer('priceLowVAT', $this->normalizerFactory->getClosure('float'));
57 1
        $resolver->setNormalizer('priceLowVatRate', $this->normalizerFactory->getClosure('float'));
58 1
        $resolver->setNormalizer('priceLowSum', $this->normalizerFactory->getClosure('float'));
59 1
        $resolver->setNormalizer('priceHigh', $this->normalizerFactory->getClosure('float'));
60 1
        $resolver->setNormalizer('priceHighVAT', $this->normalizerFactory->getClosure('float'));
61 1
        $resolver->setNormalizer('priceHighVatRate', $this->normalizerFactory->getClosure('float'));
62 1
        $resolver->setNormalizer('priceHighSum', $this->normalizerFactory->getClosure('float'));
63
    }
64
}
65