Failed Conditions
Push — annotation-metadata ( 414255 )
by Michael
02:42
created

PropertyMetadataBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 25
dl 0
loc 68
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0

6 Methods

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