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