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

VirtualProperty   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 38
rs 10
c 1
b 0
f 0
ccs 8
cts 9
cp 0.8889
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({"METHOD", "CLASS"})
10
 *
11
 * @author Alexander Klimenkov <[email protected]>
12
 */
13
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
14
final class VirtualProperty
15
{
16
    use AnnotationUtilsTrait;
17
18
    /**
19
     * @var string|null
20
     */
21 36
    public $exp = null;
22
23 36
    /**
24 8
     * @var string|null
25 8
     */
26
    public $name = null;
27
28 36
    /**
29 9
     * @var array
30
     */
31
    public $options = [];
32 9
33
    public function __construct($values = [], ?string $name = null, ?string $exp = null, array $options = [])
34 36
    {
35
        $vars = get_defined_vars();
36
        unset($vars['options']);
37
        $this->loadAnnotationParameters($vars);
38
39
        if (0 !== count($options)) {
40
            $this->options = $options;
41
        }
42
43
        foreach ($options as $option) {
44
            if (is_array($option) && class_exists($option[0])) {
45
                $this->options[] = new $option[0]([], ...$option[1]);
46
47
                continue;
48
            }
49
50
            $this->options[] = $option;
51
        }
52
    }
53
}
54