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