Passed
Pull Request — master (#247)
by Michael
02:00
created

PropertyMetadata   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 16
dl 0
loc 64
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A isDefault() 0 3 1
A __construct() 0 12 1
A getEnum() 0 3 1
A getType() 0 3 1
A isRequired() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Metadata;
6
7
/**
8
 * Property metadata represents information about the definition of a single property of an annotation, it's name,
9
 * accepted types, whether it's required and whether it's default.
10
 */
11
final class PropertyMetadata
12
{
13
    /** @var string */
14
    private $name;
15
16
    /** @var array<string, string>|null */
17
    private $type;
18
19
    /** @var bool */
20
    private $required;
21
22
    /** @var bool */
23
    private $default;
24
25
    /** @var array<int|float|string|bool>|null */
26
    private $enum;
27
28
    /**
29
     * @param array<string, string>             $type
30
     * @param array<int|float|string|bool>|null $enum
31
     */
32 294
    public function __construct(
33
        string $name,
34
        ?array $type,
35
        bool $required = false,
36
        bool $default = false,
37
        ?array $enum = null
38
    ) {
39 294
        $this->name     = $name;
40 294
        $this->type     = $type;
41 294
        $this->required = $required;
42 294
        $this->default  = $default;
43 294
        $this->enum     = $enum;
44 294
    }
45
46 294
    public function getName() : string
47
    {
48 294
        return $this->name;
49
    }
50
51 205
    public function isRequired() : bool
52
    {
53 205
        return $this->required;
54
    }
55
56
    /**
57
     * @return array<string, string>|null
58
     */
59 234
    public function getType() : ?array
60
    {
61 234
        return $this->type;
62
    }
63
64 294
    public function isDefault() : bool
65
    {
66 294
        return $this->default;
67
    }
68
69
    /**
70
     * @return array<int|float|string|bool>|null
71
     */
72 234
    public function getEnum() : ?array
73
    {
74 234
        return $this->enum;
75
    }
76
}
77