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

XmlDiscriminator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 5
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 (array_key_exists('value', $values)) {
32
            $namespace = $values['value'];
33
        }
34
35
        if (array_key_exists('attribute', $values)) {
36
            $attribute = $values['attribute'];
37
        }
38
39
        if (array_key_exists('cdata', $values)) {
40
            $cdata = $values['cdata'];
41
        }
42
43
        if (array_key_exists('namespace', $values)) {
44
            $namespace = $values['namespace'];
45
        }
46
47
        $this->attribute = $attribute;
48
        $this->cdata = $cdata;
49
        $this->namespace = $namespace;
50
    }
51
}
52