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