Completed
Pull Request — master (#1320)
by
unknown
03:30 queued 13s
created

XmlElement::__construct()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
c 0
b 0
f 0
nc 5
nop 3
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer\Annotation;
6
7
/**
8
 * @Annotation
9
 * @Target({"PROPERTY", "METHOD","ANNOTATION"})
10
 */
11
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
12
final class XmlElement
13
{
14
    /**
15
     * @var bool
16
     */
17
    public $cdata = true;
18
19
    /**
20
     * @var string|null
21
     */
22
    public $namespace = null;
23
24
    public function __construct(array $values = [], bool $cdata = true, ?string $namespace = null)
25
    {
26
        if (0 !== count($values)) {
27
            if (array_key_exists('cdata', $values)) {
28
                $cdata = $values['cdata'];
29
            }
30
31
            if (array_key_exists('namespace', $values)) {
32
                $namespace = $values['namespace'];
33
            }
34
        }
35
36
        $this->cdata = $cdata;
37
        $this->namespace = $namespace;
38
    }
39
}
40