Passed
Push — master ( 067151...1e051c )
by Petr
13:11
created

Header::setData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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\Bank;
13
14
use Riesenia\Pohoda\Common;
15
use Riesenia\Pohoda\Document\AbstractHeader;
16
17
class Header extends AbstractHeader
18
{
19
    /** @var string[] */
20
    protected array $refElements = ['account', 'accounting', 'classificationVAT', 'classificationKVDPH', 'paymentAccount', 'centre', 'activity', 'contract', 'MOSS', 'evidentiaryResourcesMOSS'];
21
22
    /** @var string[] */
23
    protected array $elements = ['bankType', 'account', 'statementNumber', 'symVar', 'dateStatement', 'datePayment', 'accounting', 'classificationVAT', 'classificationKVDPH', 'text', 'partnerIdentity', 'myIdentity', 'paymentAccount', 'symConst', 'symSpec', 'symPar', 'centre', 'activity', 'contract', 'MOSS', 'evidentiaryResourcesMOSS', 'accountingPeriodMOSS', 'note', 'intNote'];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 5
    public function setData(array $data): parent
29
    {
30
        // process report
31 5
        if (isset($data['statementNumber'])) {
32 5
            $statementNumber = new StatementNumber($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
33 5
            $data['statementNumber'] = $statementNumber->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['statementNumber']);
34
        }
35
36 5
        return parent::setData($data);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
43
    {
44 1
        parent::configureOptions($resolver);
45
46
        // validate / format options
47 1
        $resolver->setAllowedValues('bankType', ['receipt', 'expense']);
48 1
        $resolver->setNormalizer('symVar', $this->normalizerFactory->getClosure('string20'));
49 1
        $resolver->setNormalizer('dateStatement', $this->normalizerFactory->getClosure('date'));
50 1
        $resolver->setNormalizer('datePayment', $this->normalizerFactory->getClosure('date'));
51 1
        $resolver->setNormalizer('text', $this->normalizerFactory->getClosure('string96'));
52 1
        $resolver->setNormalizer('symConst', $this->normalizerFactory->getClosure('string4'));
53 1
        $resolver->setNormalizer('symSpec', $this->normalizerFactory->getClosure('string16'));
54 1
        $resolver->setNormalizer('symPar', $this->normalizerFactory->getClosure('string20'));
55 1
        $resolver->setNormalizer('accountingPeriodMOSS', $this->normalizerFactory->getClosure('string7'));
56
    }
57
}
58