MyAddress   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 13
c 0
b 0
f 0
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 16 3
A configureOptions() 0 4 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;
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