Passed
Push — master ( 4e4741...4fd99d )
by Asmir
03:38 queued 01:04
created

Discriminator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 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 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 (array_key_exists('field', $values)) {
29
            $field = $values['field'];
30
        }
31
32
        if (array_key_exists('groups', $values)) {
33
            $groups = $values['groups'];
34
        }
35
36
        if (array_key_exists('map', $values)) {
37
            $map = $values['map'];
38
        }
39
40
        if (array_key_exists('disabled', $values)) {
41
            $disabled = $values['disabled'];
42
        }
43
44
        $this->field = $field;
45
        $this->groups = $groups;
46
        $this->map = $map;
47
        $this->disabled = $disabled;
48
    }
49
}
50