Total Complexity | 6 |
Total Lines | 64 |
Duplicated Lines | 0 % |
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 | public function __construct(string $name) |
||
30 | { |
||
31 | $this->name = $name; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param string[] $type |
||
36 | */ |
||
37 | public function withType(array $type) : self |
||
42 | } |
||
43 | |||
44 | public function withBeingRequired() : self |
||
45 | { |
||
46 | $this->required = true; |
||
47 | |||
48 | return $this; |
||
49 | } |
||
50 | |||
51 | public function withBeingDefault() : self |
||
52 | { |
||
53 | $this->default = true; |
||
54 | |||
55 | return $this; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param mixed[] $enum |
||
60 | */ |
||
61 | public function withEnum(array $enum) : self |
||
62 | { |
||
63 | $this->enum = $enum; |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | public function build() : PropertyMetadata |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 |