Header::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 25
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 29
ccs 25
cts 25
cp 1
rs 9.536
c 0
b 0
f 0
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\AddressBook;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common;
16
use Riesenia\Pohoda\Type\Address;
17
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding;
18
19
class Header extends AbstractAgenda
20
{
21
    use Common\AddParameterTrait;
22
23
    /** @var string[] */
24
    protected array $refElements = ['paymentType', 'centre', 'activity', 'contract', 'number', 'accountingReceivedInvoice', 'accountingIssuedInvoice', 'classificationVATReceivedInvoice', 'classificationVATIssuedInvoice', 'classificationKVDPHReceivedInvoice', 'classificationKVDPHIssuedInvoice', 'accountForInvoicing', 'foreignCurrency'];
25
26
    /** @var string[] */
27
    protected array $elements = ['identity', 'region', 'phone', 'mobil', 'fax', 'email', 'web', 'ICQ', 'Skype', 'GPS', 'credit', 'priceIDS', 'maturity', 'maturityCommitments', 'paymentType', 'agreement', 'number', 'ost1', 'ost2', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'markRecord', 'message', 'note', 'intNote', 'accountingReceivedInvoice', 'accountingIssuedInvoice', 'classificationVATReceivedInvoice', 'classificationVATIssuedInvoice', 'classificationKVDPHReceivedInvoice', 'classificationKVDPHIssuedInvoice', 'accountForInvoicing', 'foreignCurrency', 'centre', 'activity', 'contract', 'adGroup'];
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 6
    public function setData(array $data): parent
33
    {
34
        // process identity
35 6
        if (isset($data['identity'])) {
36 6
            $identity = new Address($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
37 6
            $data['identity'] = $identity->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['identity']);
38
        }
39
40 6
        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...
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 5
    public function getXML(): \SimpleXMLElement
47
    {
48 5
        $xml = $this->createXML()->addChild('adb:addressbookHeader', '', $this->namespace('adb'));
49
50 5
        $this->addElements($xml, \array_merge($this->elements, ['parameters']), 'adb');
51
52 5
        return $xml;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
59
    {
60
        // available options
61 1
        $resolver->setDefined($this->elements);
62
63
        // validate / format options
64 1
        $resolver->setNormalizer('region', $this->normalizerFactory->getClosure('string32'));
65 1
        $resolver->setNormalizer('phone', $this->normalizerFactory->getClosure('string40'));
66 1
        $resolver->setNormalizer('mobil', $this->normalizerFactory->getClosure('string24'));
67 1
        $resolver->setNormalizer('fax', $this->normalizerFactory->getClosure('string24'));
68 1
        $resolver->setNormalizer('email', $this->normalizerFactory->getClosure('string98'));
69 1
        $resolver->setNormalizer('web', $this->normalizerFactory->getClosure('string32'));
70 1
        $resolver->setNormalizer('ICQ', $this->normalizerFactory->getClosure('string12'));
71 1
        $resolver->setNormalizer('Skype', $this->normalizerFactory->getClosure('string32'));
72 1
        $resolver->setNormalizer('GPS', $this->normalizerFactory->getClosure('string38'));
73 1
        $resolver->setNormalizer('credit', $this->normalizerFactory->getClosure('float'));
74 1
        $resolver->setNormalizer('priceIDS', $this->normalizerFactory->getClosure('string10'));
75 1
        $resolver->setNormalizer('maturity', $this->normalizerFactory->getClosure('int'));
76 1
        $resolver->setNormalizer('agreement', $this->normalizerFactory->getClosure('string12'));
77 1
        $resolver->setNormalizer('ost1', $this->normalizerFactory->getClosure('string8'));
78 1
        $resolver->setNormalizer('ost2', $this->normalizerFactory->getClosure('string8'));
79 1
        $resolver->setNormalizer('p1', $this->normalizerFactory->getClosure('bool'));
80 1
        $resolver->setNormalizer('p2', $this->normalizerFactory->getClosure('bool'));
81 1
        $resolver->setNormalizer('p3', $this->normalizerFactory->getClosure('bool'));
82 1
        $resolver->setNormalizer('p4', $this->normalizerFactory->getClosure('bool'));
83 1
        $resolver->setNormalizer('p5', $this->normalizerFactory->getClosure('bool'));
84 1
        $resolver->setNormalizer('p6', $this->normalizerFactory->getClosure('bool'));
85 1
        $resolver->setNormalizer('markRecord', $this->normalizerFactory->getClosure('bool'));
86 1
        $resolver->setNormalizer('message', $this->normalizerFactory->getClosure('string64'));
87
    }
88
}
89