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