Completed
Pull Request — master (#1320)
by
unknown
03:30 queued 13s
created

Accessor::__construct()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 9
c 0
b 0
f 0
nc 9
nop 3
dl 0
loc 18
rs 9.6111
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 (0 !== count($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