MyAddress::setData()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.9666
cc 3
nc 4
nop 1
crap 3
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
17
/**
18
 * @property array{
19
 *     address?: AddressInternetType,
20
 *     establishment?: EstablishmentType,
21
 * } $data
22
 */
23
class MyAddress extends AbstractAgenda
24
{
25
    use Common\SetNamespaceTrait;
26
27
    /** @var string[] */
28
    protected array $elements = ['address', 'establishment'];
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 28
    public function setData(array $data): parent
34
    {
35
        // process address
36 28
        if (isset($data['address'])) {
37 27
            $address = new AddressInternetType($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory);
38 27
            $address->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['address']);
39 27
            $data['address'] = $address;
40
        }
41
        // process establishment
42 28
        if (isset($data['establishment'])) {
43 1
            $establishment = new EstablishmentType($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory);
44 1
            $establishment->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['establishment']);
45 1
            $data['establishment'] = $establishment;
46
        }
47
48 28
        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...
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    protected function configureOptions(Common\OptionsResolver $resolver): void
55
    {
56
        // available options
57 1
        $resolver->setDefined($this->elements);
58
    }
59
}
60