| Total Complexity | 6 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class PropertyMetadataBuilder |
||
| 11 | { |
||
| 12 | /** @var string */ |
||
| 13 | private $name; |
||
| 14 | |||
| 15 | /** @var string[]|null */ |
||
| 16 | private $type; |
||
| 17 | |||
| 18 | /** @var bool */ |
||
| 19 | private $required = false; |
||
| 20 | |||
| 21 | /** @var bool */ |
||
| 22 | private $default = false; |
||
| 23 | |||
| 24 | /** @var mixed[]|null */ |
||
| 25 | private $enum; |
||
| 26 | |||
| 27 | 229 | public function __construct(string $name) |
|
| 28 | { |
||
| 29 | 229 | $this->name = $name; |
|
| 30 | 229 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @param string[] $type |
||
| 34 | */ |
||
| 35 | 183 | public function withType(array $type) : self |
|
| 41 | } |
||
| 42 | |||
| 43 | 10 | public function withBeingRequired() : self |
|
| 44 | { |
||
| 45 | 10 | $new = clone $this; |
|
| 46 | 10 | $new->required = true; |
|
| 47 | |||
| 48 | 10 | return $new; |
|
| 49 | } |
||
| 50 | |||
| 51 | 157 | public function withBeingDefault() : self |
|
| 52 | { |
||
| 53 | 157 | $new = clone $this; |
|
| 54 | 157 | $new->default = true; |
|
| 55 | |||
| 56 | 157 | return $new; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param mixed[] $values |
||
| 61 | */ |
||
| 62 | 5 | public function withEnum(array $enum) : self |
|
| 63 | { |
||
| 64 | 5 | $new = clone $this; |
|
| 65 | 5 | $new->enum = $enum; |
|
| 66 | |||
| 67 | 5 | return $new; |
|
| 68 | } |
||
| 69 | |||
| 70 | 227 | public function build() : PropertyMetadata |
|
| 78 | ); |
||
| 79 | } |
||
| 80 | } |
||
| 81 |