Passed
Pull Request — master (#1320)
by
unknown
03:01
created

Discriminator::__construct()   A

Complexity

Conditions 6
Paths 17

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 13
c 0
b 0
f 0
nc 17
nop 5
dl 0
loc 24
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
class Discriminator
13
{
14
    /** @var array<string> */
15
    public $map = [];
16
17
    /** @var string */
18
    public $field = 'type';
19
20
    /** @var bool */
21
    public $disabled = false;
22
23
    /** @var string[] */
24
    public $groups = [];
25
26
    public function __construct(array $values = [], string $field = 'type', array $groups = [], array $map = [], bool $disabled = false)
27
    {
28
        if ([] !== $values) {
29
            if (array_key_exists('field', $values)) {
30
                $field = $values['field'];
31
            }
32
33
            if (array_key_exists('groups', $values)) {
34
                $groups = $values['groups'];
35
            }
36
37
            if (array_key_exists('map', $values)) {
38
                $map = $values['map'];
39
            }
40
41
            if (array_key_exists('disabled', $values)) {
42
                $disabled = $values['disabled'];
43
            }
44
        }
45
46
        $this->field = $field;
47
        $this->groups = $groups;
48
        $this->map = $map;
49
        $this->disabled = $disabled;
50
    }
51
}
52