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

PropertyMetadataBuilder   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 21
dl 0
loc 64
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A withType() 0 5 1
A build() 0 8 1
A withBeingRequired() 0 5 1
A withEnum() 0 5 1
A withBeingDefault() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Metadata\Builder;
6
7
use Doctrine\Annotations\Metadata\PropertyMetadata;
8
9
/**
10
 * @internal
11
 */
12
final class PropertyMetadataBuilder
13
{
14
    /** @var string */
15
    private $name;
16
17
    /** @var string[]|null */
18
    private $type;
19
20
    /** @var bool */
21
    private $required = false;
22
23
    /** @var bool */
24
    private $default = false;
25
26
    /** @var array<int|float|string|bool>|null */
27
    private $enum;
28
29 239
    public function __construct(string $name)
30
    {
31 239
        $this->name = $name;
32 239
    }
33
34
    /**
35
     * @param string[] $type
36
     */
37 174
    public function withType(array $type) : self
38
    {
39 174
        $this->type = $type;
40
41 174
        return $this;
42
    }
43
44 4
    public function withBeingRequired() : self
45
    {
46 4
        $this->required = true;
47
48 4
        return $this;
49
    }
50
51 169
    public function withBeingDefault() : self
52
    {
53 169
        $this->default = true;
54
55 169
        return $this;
56
    }
57
58
    /**
59
     * @param array<int|float|string|bool>|null $enum
60
     */
61 4
    public function withEnum(array $enum) : self
62
    {
63 4
        $this->enum = $enum;
64
65 4
        return $this;
66
    }
67
68 237
    public function build() : PropertyMetadata
69
    {
70 237
        return new PropertyMetadata(
71 237
            $this->name,
72 237
            $this->type,
73 237
            $this->required,
74 237
            $this->default,
75 237
            $this->enum
76
        );
77
    }
78
}
79