Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | final class AnnotationMetadataBuilder |
||
13 | { |
||
14 | /** @var string */ |
||
15 | private $name; |
||
16 | |||
17 | /** @var AnnotationTarget */ |
||
18 | private $target; |
||
19 | |||
20 | /** @var PropertyMetadata[] */ |
||
21 | private $properties = []; |
||
22 | |||
23 | /** @var bool */ |
||
24 | private $usesConstructor = false; |
||
25 | |||
26 | public function __construct(string $name) |
||
27 | { |
||
28 | $this->name = $name; |
||
29 | $this->target = AnnotationTarget::all(); |
||
30 | } |
||
31 | |||
32 | public function withTarget(AnnotationTarget $target) : self |
||
33 | { |
||
34 | $new = clone $this; |
||
35 | $new->target = $target; |
||
36 | |||
37 | return $new; |
||
38 | } |
||
39 | |||
40 | public function withUsingConstructor() : self |
||
41 | { |
||
42 | $new = clone $this; |
||
43 | $new->usesConstructor = true; |
||
44 | |||
45 | return $new; |
||
46 | } |
||
47 | |||
48 | public function withProperty(PropertyMetadata $property) : self |
||
49 | { |
||
50 | $new = clone $this; |
||
51 | $new->properties[] = $property; |
||
52 | |||
53 | return $new; |
||
54 | } |
||
55 | |||
56 | public function build() : AnnotationMetadata |
||
63 | ); |
||
64 | } |
||
65 | } |
||
66 |