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

XmlDiscriminator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
c 0
b 0
f 0
dl 0
loc 41
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 6
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
class XmlDiscriminator
13
{
14
    /**
15
     * @var bool
16
     */
17
    public $attribute = false;
18
19
    /**
20
     * @var bool
21
     */
22
    public $cdata = true;
23
24
    /**
25
     * @var string|null
26
     */
27
    public $namespace = null;
28
29
    public function __construct(array $values = [], bool $attribute = false, bool $cdata = false, ?string $namespace = null)
30
    {
31
        if (0 !== count($values)) {
32
            if (array_key_exists('value', $values)) {
33
                $namespace = $values['value'];
34
            }
35
36
            if (array_key_exists('attribute', $values)) {
37
                $attribute = $values['attribute'];
38
            }
39
40
            if (array_key_exists('cdata', $values)) {
41
                $cdata = $values['cdata'];
42
            }
43
44
            if (array_key_exists('namespace', $values)) {
45
                $namespace = $values['namespace'];
46
            }
47
        }
48
49
        $this->attribute = $attribute;
50
        $this->cdata = $cdata;
51
        $this->namespace = $namespace;
52
    }
53
}
54