| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| 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 | 294 | public function __construct(string $name) |
|
| 27 | { |
||
| 28 | 294 | $this->name = $name; |
|
| 29 | 294 | $this->target = AnnotationTarget::all(); |
|
| 30 | 294 | } |
|
| 31 | |||
| 32 | 215 | public function withTarget(AnnotationTarget $target) : self |
|
| 33 | { |
||
| 34 | 215 | $new = clone $this; |
|
| 35 | 215 | $new->target = $target; |
|
| 36 | |||
| 37 | 215 | return $new; |
|
| 38 | } |
||
| 39 | |||
| 40 | 135 | public function withUsingConstructor() : self |
|
| 41 | { |
||
| 42 | 135 | $new = clone $this; |
|
| 43 | 135 | $new->usesConstructor = true; |
|
| 44 | |||
| 45 | 135 | return $new; |
|
| 46 | } |
||
| 47 | |||
| 48 | 226 | public function withProperty(PropertyMetadata $property) : self |
|
| 49 | { |
||
| 50 | 226 | $new = clone $this; |
|
| 51 | 226 | $new->properties[] = $property; |
|
| 52 | |||
| 53 | 226 | return $new; |
|
| 54 | } |
||
| 55 | |||
| 56 | 283 | public function build() : AnnotationMetadata |
|
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |