Passed
Pull Request — master (#1332)
by Asmir
02:46
created

Accessor::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 8
nop 3
dl 0
loc 16
rs 10
c 0
b 0
f 0
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 (array_key_exists('value', $values)) {
29
            $getter = $values['value'];
30
        }
31
32
        if (array_key_exists('getter', $values)) {
33
            $getter = $values['getter'];
34
        }
35
36
        if (array_key_exists('setter', $values)) {
37
            $setter = $values['setter'];
38
        }
39
40
        $this->getter = $getter;
41
        $this->setter = $setter;
42
    }
43
}
44