|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Aweapi\Openapi\Builders; |
|
6
|
|
|
|
|
7
|
|
|
use Aweapi\Openapi\Objects; |
|
8
|
|
|
use Aweapi\Openapi\Objects\ParameterAggregate; |
|
9
|
|
|
|
|
10
|
|
|
final class ParameterBuilder implements Objects\ParameterFactory |
|
11
|
|
|
{ |
|
12
|
|
|
use Properties\OptionalExtensions; |
|
13
|
|
|
|
|
14
|
|
|
private $allowEmptyValue = false; |
|
15
|
|
|
|
|
16
|
|
|
private $allowReserved = false; |
|
17
|
|
|
|
|
18
|
|
|
private $content; |
|
19
|
|
|
|
|
20
|
|
|
private $deprecated = false; |
|
21
|
|
|
|
|
22
|
|
|
private $description; |
|
23
|
|
|
|
|
24
|
|
|
private $examples; |
|
25
|
|
|
|
|
26
|
|
|
private $explode; |
|
27
|
|
|
|
|
28
|
|
|
private $in; |
|
29
|
|
|
|
|
30
|
|
|
private $name; |
|
31
|
|
|
|
|
32
|
|
|
private $required; |
|
33
|
|
|
|
|
34
|
|
|
private $schema; |
|
35
|
|
|
|
|
36
|
|
|
private $style; |
|
37
|
|
|
|
|
38
|
7 |
|
public function createParameter(): Objects\Parameter |
|
39
|
|
|
{ |
|
40
|
7 |
|
return new Objects\Parameter( |
|
41
|
7 |
|
$this->getName(), |
|
42
|
7 |
|
$this->getIn(), |
|
43
|
7 |
|
$this->getSchema() ? $this->getSchema()->createSchemaAggregate() : null, |
|
44
|
7 |
|
$this->getContent() ? $this->getContent()->createMediaTypes() : null, |
|
45
|
7 |
|
$this->getDescription(), |
|
46
|
7 |
|
$this->isRequired(), |
|
47
|
7 |
|
$this->isDeprecated(), |
|
48
|
7 |
|
$this->isAllowEmptyValue(), |
|
49
|
7 |
|
$this->getStyle(), |
|
50
|
7 |
|
$this->isExplode(), |
|
51
|
7 |
|
$this->isAllowReserved(), |
|
52
|
7 |
|
$this->getExamples() ? $this->getExamples()->createExamples() : null, |
|
53
|
7 |
|
$this->getExtensions() |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
2 |
|
public function createParameterAggregate(): ParameterAggregate |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->createParameter(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function setAllowEmptyValue(bool $allowEmptyValue): self |
|
63
|
|
|
{ |
|
64
|
1 |
|
$this->allowEmptyValue = $allowEmptyValue; |
|
65
|
|
|
|
|
66
|
1 |
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
public function setAllowReserved(bool $allowReserved): self |
|
70
|
|
|
{ |
|
71
|
1 |
|
$this->allowReserved = $allowReserved; |
|
72
|
|
|
|
|
73
|
1 |
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setContent(Objects\MediaTypesFactory $content): self |
|
77
|
|
|
{ |
|
78
|
|
|
$this->content = $content; |
|
79
|
|
|
|
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
1 |
|
public function setDeprecated(bool $deprecated): self |
|
84
|
|
|
{ |
|
85
|
1 |
|
$this->deprecated = $deprecated; |
|
86
|
|
|
|
|
87
|
1 |
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
1 |
|
public function setDescription(string $description): self |
|
91
|
|
|
{ |
|
92
|
1 |
|
$this->description = $description; |
|
93
|
|
|
|
|
94
|
1 |
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
1 |
|
public function setExamples(Objects\ExamplesFactory $examples): self |
|
98
|
|
|
{ |
|
99
|
1 |
|
$this->examples = $examples; |
|
100
|
|
|
|
|
101
|
1 |
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
1 |
|
public function setExplode(bool $explode): self |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->explode = $explode; |
|
107
|
|
|
|
|
108
|
1 |
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
7 |
|
public function setIn(string $in): self |
|
112
|
|
|
{ |
|
113
|
7 |
|
$this->in = $in; |
|
114
|
|
|
|
|
115
|
7 |
|
return $this; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
7 |
|
public function setName(string $name): self |
|
119
|
|
|
{ |
|
120
|
7 |
|
$this->name = $name; |
|
121
|
|
|
|
|
122
|
7 |
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
1 |
|
public function setRequired(bool $required): self |
|
126
|
|
|
{ |
|
127
|
1 |
|
$this->required = $required; |
|
128
|
|
|
|
|
129
|
1 |
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
1 |
|
public function setSchema(Objects\SchemaAggregateFactory $schema): self |
|
133
|
|
|
{ |
|
134
|
1 |
|
$this->schema = $schema; |
|
135
|
|
|
|
|
136
|
1 |
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
1 |
|
public function setStyle(string $style): self |
|
140
|
|
|
{ |
|
141
|
1 |
|
$this->style = $style; |
|
142
|
|
|
|
|
143
|
1 |
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
7 |
|
private function getContent(): ?Objects\MediaTypesFactory |
|
147
|
|
|
{ |
|
148
|
7 |
|
return $this->content; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
7 |
|
private function getDescription(): ?string |
|
152
|
|
|
{ |
|
153
|
7 |
|
return $this->description; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
7 |
|
private function getExamples(): ?Objects\ExamplesFactory |
|
157
|
|
|
{ |
|
158
|
7 |
|
return $this->examples; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
7 |
|
private function getIn(): string |
|
162
|
|
|
{ |
|
163
|
7 |
|
return $this->in; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
7 |
|
private function getName(): string |
|
167
|
|
|
{ |
|
168
|
7 |
|
return $this->name; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
7 |
|
private function getSchema(): ?Objects\SchemaAggregateFactory |
|
172
|
|
|
{ |
|
173
|
7 |
|
return $this->schema; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
7 |
|
private function getStyle(): ?string |
|
177
|
|
|
{ |
|
178
|
7 |
|
return $this->style; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
7 |
|
private function isAllowEmptyValue(): bool |
|
182
|
|
|
{ |
|
183
|
7 |
|
return $this->allowEmptyValue; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
7 |
|
private function isAllowReserved(): bool |
|
187
|
|
|
{ |
|
188
|
7 |
|
return $this->allowReserved; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
7 |
|
private function isDeprecated(): bool |
|
192
|
|
|
{ |
|
193
|
7 |
|
return $this->deprecated; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
7 |
|
private function isExplode(): ?bool |
|
197
|
|
|
{ |
|
198
|
7 |
|
return $this->explode; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
7 |
|
private function isRequired(): ?bool |
|
202
|
|
|
{ |
|
203
|
7 |
|
return $this->required; |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|