Failed Conditions
Pull Request — new-parser-ast-metadata (#3)
by
unknown
02:22
created

AnnotationMetadataBuilder::withTarget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations;
6
7
use Doctrine\Annotations\Metadata\AnnotationMetadata;
8
use Doctrine\Annotations\Metadata\AnnotationTarget;
9
use Doctrine\Annotations\Metadata\PropertyMetadata;
10
11
final class AnnotationMetadataBuilder
12
{
13
    /** @var string */
14
    private $name;
15
16
    /** @var AnnotationTarget */
17
    private $target;
18
19
    /** @var bool */
20
    private $hasConstructor;
21
22
    /** @var PropertyMetadata[] */
23
    private $properties;
24
25
    public function __construct()
26
    {
27
        $this->name           = 'foo';
28
        $this->target         = new AnnotationTarget(AnnotationTarget::TARGET_ALL);
29
        $this->hasConstructor = false;
30
        $this->properties     = [];
31
    }
32
33
    public function withTarget(AnnotationTarget $target) : self
34
    {
35
        $this->target = $target;
36
37
        return $this;
38
    }
39
40
    public function hasConstructor() : self
41
    {
42
        $this->hasConstructor = true;
43
44
        return $this;
45
    }
46
47
    public function withProperties(PropertyMetadata ...$properties) : self
48
    {
49
        $this->properties = $properties;
50
51
        return $this;
52
    }
53
54
    public function build() : AnnotationMetadata
55
    {
56
        return new AnnotationMetadata(
57
            $this->name,
58
            $this->target,
59
            $this->hasConstructor,
60
            $this->properties
61
        );
62
    }
63
}
64