AddressType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 21
c 1
b 0
f 1
dl 0
loc 43
ccs 20
cts 20
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 20 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\Type;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common\OptionsResolver;
16
17
class AddressType extends AbstractAgenda
18
{
19
    /** @var string[] */
20
    protected array $refElements = ['country'];
21
22
    /** @var string[] */
23
    protected array $elements = ['company', 'division', 'name', 'city', 'street', 'zip', 'ico', 'dic', 'VATPayerType', 'icDph', 'country', 'phone', 'mobilPhone', 'fax', 'email'];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 18
    public function getXML(): \SimpleXMLElement
29
    {
30 18
        $xml = $this->createXML()->addChild('typ:address', '', $this->namespace('typ'));
31
32 18
        $this->addElements($xml, $this->elements, 'typ');
33
34 18
        return $xml;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    protected function configureOptions(OptionsResolver $resolver): void
41
    {
42
        // available options
43 1
        $resolver->setDefined($this->elements);
44
45
        // validate / format options
46 1
        $resolver->setNormalizer('company', $this->normalizerFactory->getClosure('string255'));
47 1
        $resolver->setNormalizer('division', $this->normalizerFactory->getClosure('string32'));
48 1
        $resolver->setNormalizer('name', $this->normalizerFactory->getClosure('string32'));
49 1
        $resolver->setNormalizer('city', $this->normalizerFactory->getClosure('string45'));
50 1
        $resolver->setNormalizer('street', $this->normalizerFactory->getClosure('string45'));
51 1
        $resolver->setNormalizer('zip', $this->normalizerFactory->getClosure('string15'));
52 1
        $resolver->setNormalizer('ico', $this->normalizerFactory->getClosure('string15'));
53 1
        $resolver->setNormalizer('dic', $this->normalizerFactory->getClosure('string18'));
54 1
        $resolver->setAllowedValues('VATPayerType', ['payer', 'non-payer', '']);
55 1
        $resolver->setNormalizer('icDph', $this->normalizerFactory->getClosure('string18'));
56 1
        $resolver->setNormalizer('phone', $this->normalizerFactory->getClosure('string40'));
57 1
        $resolver->setNormalizer('mobilPhone', $this->normalizerFactory->getClosure('string24'));
58 1
        $resolver->setNormalizer('fax', $this->normalizerFactory->getClosure('string24'));
59 1
        $resolver->setNormalizer('email', $this->normalizerFactory->getClosure('string98'));
60
    }
61
}
62