Passed
Pull Request — master (#1320)
by
unknown
02:40
created

XmlRoot::__construct()   A

Complexity

Conditions 6
Paths 17

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 12
c 0
b 0
f 0
nc 17
nop 4
dl 0
loc 23
rs 9.2222
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer\Annotation;
6
7
/**
8
 * @Annotation
9
 * @Target("CLASS")
10
 */
11
#[\Attribute(\Attribute::TARGET_CLASS)]
12
final class XmlRoot
13
{
14
    /**
15
     * @Required
16
     * @var string|null
17
     */
18
    public $name = null;
19
20
    /**
21
     * @var string|null
22
     */
23
    public $namespace = null;
24
25
    /**
26
     * @var string|null
27
     */
28
    public $prefix = null;
29
30
    public function __construct(array $values = [], ?string $name = null, ?string $namespace = null, ?string $prefix = null)
31
    {
32
        if ([] !== $values) {
33
            if (array_key_exists('value', $values)) {
34
                $name = $values['value'];
35
            }
36
37
            if (array_key_exists('name', $values)) {
38
                $name = $values['name'];
39
            }
40
41
            if (array_key_exists('namespace', $values)) {
42
                $namespace = $values['namespace'];
43
            }
44
45
            if (array_key_exists('prefix', $values)) {
46
                $prefix = $values['prefix'];
47
            }
48
        }
49
50
        $this->name = $name;
51
        $this->namespace = $namespace;
52
        $this->prefix = $prefix;
53
    }
54
}
55