Passed
Pull Request — master (#1332)
by Asmir
02:29
created

XmlRoot::__construct()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 16
nop 4
dl 0
loc 21
rs 9.6111
c 0
b 0
f 0
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 (array_key_exists('value', $values)) {
33
            $name = $values['value'];
34
        }
35
36
        if (array_key_exists('name', $values)) {
37
            $name = $values['name'];
38
        }
39
40
        if (array_key_exists('namespace', $values)) {
41
            $namespace = $values['namespace'];
42
        }
43
44
        if (array_key_exists('prefix', $values)) {
45
            $prefix = $values['prefix'];
46
        }
47
48
        $this->name = $name;
49
        $this->namespace = $namespace;
50
        $this->prefix = $prefix;
51
    }
52
}
53