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

Discriminator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 39
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 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 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