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

Accessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer\Annotation;
6
7
/**
8
 * @Annotation
9
 * @Target("PROPERTY")
10
 *
11
 * @author Johannes M. Schmitt <[email protected]>
12
 */
13
#[\Attribute(\Attribute::TARGET_PROPERTY)]
14
final class Accessor
15
{
16
    /**
17
     * @var string|null
18
     */
19
    public $getter = null;
20
21
    /**
22
     * @var string|null
23
     */
24
    public $setter = null;
25
26
    public function __construct(array $values = [], ?string $getter = null, ?string $setter = null)
27
    {
28
        if ([] !== $values) {
29
            if (array_key_exists('value', $values)) {
30
                $getter = $values['value'];
31
            }
32
33
            if (array_key_exists('getter', $values)) {
34
                $getter = $values['getter'];
35
            }
36
37
            if (array_key_exists('setter', $values)) {
38
                $setter = $values['setter'];
39
            }
40
        }
41
42
        $this->getter = $getter;
43
        $this->setter = $setter;
44
    }
45
}
46