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

PropertyMetadata::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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