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