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