Desc::getXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
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\Contract;
13
14
use Riesenia\Pohoda\AbstractAgenda;
15
use Riesenia\Pohoda\Common;
16
use Riesenia\Pohoda\Type\Address;
17
18
class Desc extends AbstractAgenda
19
{
20
    use Common\AddParameterTrait;
21
22
    /** @var string[] */
23
    protected array $refElements = ['number', 'responsiblePerson'];
24
25
    /** @var string[] */
26
    protected array $elements = ['number', 'datePlanStart', 'datePlanDelivery', 'dateStart', 'dateDelivery', 'dateWarranty', 'text', 'partnerIdentity', 'responsiblePerson', 'note'];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 4
    public function setData(array $data): parent
32
    {
33
        // process partner identity
34 4
        if (isset($data['partnerIdentity'])) {
35 1
            $partnerIdentity = new Address($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory);
36 1
            $data['partnerIdentity'] = $partnerIdentity->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['partnerIdentity']);
37
        }
38
39 4
        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...
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function getXML(): \SimpleXMLElement
46
    {
47 3
        $xml = $this->createXML()->addChild('con:contractDesc', '', $this->namespace('con'));
48
49 3
        $this->addElements($xml, \array_merge($this->elements, ['parameters']), 'con');
50
51 3
        return $xml;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
58
    {
59
        // available options
60 1
        $resolver->setDefined($this->elements);
61
62 1
        $resolver->setNormalizer('datePlanStart', $this->normalizerFactory->getClosure('date'));
63 1
        $resolver->setNormalizer('datePlanDelivery', $this->normalizerFactory->getClosure('date'));
64 1
        $resolver->setNormalizer('dateStart', $this->normalizerFactory->getClosure('date'));
65 1
        $resolver->setNormalizer('dateDelivery', $this->normalizerFactory->getClosure('date'));
66 1
        $resolver->setNormalizer('dateWarranty', $this->normalizerFactory->getClosure('date'));
67 1
        $resolver->setRequired('text');
68 1
        $resolver->setNormalizer('text', $this->normalizerFactory->getClosure('string90'));
69
    }
70
}
71