|
1
|
|
|
<?php |
|
2
|
|
|
namespace gossi\swagger\parts; |
|
3
|
|
|
|
|
4
|
|
|
use phootwork\collection\Map; |
|
5
|
|
|
|
|
6
|
|
|
trait TypePart { |
|
7
|
|
|
|
|
8
|
|
|
/** @var string */ |
|
9
|
|
|
private $type; |
|
10
|
|
|
|
|
11
|
|
|
/** @var string */ |
|
12
|
|
|
private $format; |
|
13
|
|
|
|
|
14
|
|
|
/** @var string */ |
|
15
|
|
|
private $collectionFormat; |
|
16
|
|
|
|
|
17
|
|
|
/** @var mixed */ |
|
18
|
|
|
private $default; |
|
19
|
|
|
|
|
20
|
|
|
/** @var float */ |
|
21
|
|
|
private $maximum; |
|
22
|
|
|
|
|
23
|
|
|
/** @var boolean */ |
|
24
|
|
|
private $exclusiveMaximum = false; |
|
25
|
|
|
|
|
26
|
|
|
/** @var float */ |
|
27
|
|
|
private $minimum; |
|
28
|
|
|
|
|
29
|
|
|
/** @var boolean */ |
|
30
|
|
|
private $exclusiveMinimum = false; |
|
31
|
|
|
|
|
32
|
|
|
/** @var int */ |
|
33
|
|
|
private $maxLength; |
|
34
|
|
|
|
|
35
|
|
|
/** @var int */ |
|
36
|
|
|
private $minLength; |
|
37
|
|
|
|
|
38
|
|
|
/** @var string */ |
|
39
|
|
|
private $pattern; |
|
40
|
|
|
|
|
41
|
|
|
/** @var int */ |
|
42
|
|
|
private $maxItems; |
|
43
|
|
|
|
|
44
|
|
|
/** @var int */ |
|
45
|
|
|
private $minItems; |
|
46
|
|
|
|
|
47
|
|
|
/** @var boolean */ |
|
48
|
|
|
private $uniqueItems; |
|
49
|
|
|
|
|
50
|
|
|
/** @var mixed */ |
|
51
|
|
|
private $enum; |
|
52
|
|
|
|
|
53
|
|
|
/** @var float */ |
|
54
|
|
|
private $multipleOf; |
|
55
|
|
|
|
|
56
|
8 |
|
private function parseType(Map $data) { |
|
57
|
8 |
|
$this->type = $data->get('type'); |
|
|
|
|
|
|
58
|
8 |
|
$this->format = $data->get('format'); |
|
|
|
|
|
|
59
|
8 |
|
$this->collectionFormat = $data->get('collectionFormat'); |
|
60
|
8 |
|
$this->default = $data->get('default'); |
|
|
|
|
|
|
61
|
8 |
|
$this->maximum = $data->get('maximum'); |
|
|
|
|
|
|
62
|
8 |
|
$this->exclusiveMaximum = $data->has('exclusiveMaximum') && $data->get('exclusiveMaximum'); |
|
63
|
8 |
|
$this->minimum = $data->get('minimum'); |
|
|
|
|
|
|
64
|
8 |
|
$this->exclusiveMinimum = $data->has('exclusiveMinimum') && $data->get('exclusiveMinimum'); |
|
65
|
8 |
|
$this->maxLength = $data->get('maxLength'); |
|
|
|
|
|
|
66
|
8 |
|
$this->minLength = $data->get('minLength'); |
|
|
|
|
|
|
67
|
8 |
|
$this->pattern = $data->get('pattern'); |
|
|
|
|
|
|
68
|
8 |
|
$this->maxItems = $data->get('maxItems'); |
|
|
|
|
|
|
69
|
8 |
|
$this->minItems = $data->get('minItems'); |
|
|
|
|
|
|
70
|
8 |
|
$this->uniqueItems = $data->has('uniqueItems') && $data->get('uniqueItems'); |
|
|
|
|
|
|
71
|
8 |
|
$this->enum = $data->get('enum'); |
|
|
|
|
|
|
72
|
8 |
|
$this->multipleOf = $data->get('multipleOf'); |
|
|
|
|
|
|
73
|
8 |
|
} |
|
74
|
|
|
|
|
75
|
5 |
|
private function getTypeExportFields() { |
|
76
|
5 |
|
return ['type', 'format', 'collectionFormat', 'default', 'maximum', 'exclusiveMaximum', |
|
77
|
5 |
|
'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', 'maxItems', |
|
78
|
5 |
|
'minItems', 'uniqueItems', 'enum', 'multipleOf' |
|
79
|
5 |
|
]; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function getType() { |
|
87
|
1 |
|
return $this->type; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* |
|
92
|
|
|
* @param string $type |
|
93
|
|
|
* @return $this |
|
94
|
|
|
*/ |
|
95
|
|
|
public function setType($type) { |
|
96
|
|
|
$this->type = $type; |
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* |
|
102
|
|
|
* @return string |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getFormat() { |
|
105
|
|
|
return $this->format; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Sets the extending format for the type |
|
110
|
|
|
* |
|
111
|
|
|
* @param string $format |
|
112
|
|
|
* @return $this |
|
113
|
|
|
*/ |
|
114
|
|
|
public function setFormat($format) { |
|
115
|
|
|
$this->format = $format; |
|
116
|
|
|
return $this; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* |
|
121
|
|
|
* @return string |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getCollectionFormat() { |
|
124
|
|
|
return $this->collectionFormat; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Determines the format of the array if type array is used. Possible values are: |
|
129
|
|
|
* |
|
130
|
|
|
* - `csv` - comma separated values `foo,bar`. |
|
131
|
|
|
* - `ssv` - space separated values `foo bar`. |
|
132
|
|
|
* - `tsv` - tab separated values `foo\tbar`. |
|
133
|
|
|
* - `pipes` - pipe separated values `foo|bar`. |
|
134
|
|
|
* - `multi` - corresponds to multiple parameter instances instead of multiple values for a |
|
135
|
|
|
* single instance `foo=bar&foo=baz`. This is valid only for parameters in "query" or "formData". |
|
136
|
|
|
* |
|
137
|
|
|
* Default value is `csv`. |
|
138
|
|
|
* |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $collectionFormat |
|
141
|
|
|
* @return $this |
|
142
|
|
|
*/ |
|
143
|
|
|
public function setCollectionFormat($collectionFormat) { |
|
144
|
|
|
$this->collectionFormat = $collectionFormat; |
|
145
|
|
|
return $this; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* |
|
150
|
|
|
* @return mixed |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getDefault() { |
|
153
|
|
|
return $this->default; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* |
|
158
|
|
|
* @param mixed $default |
|
159
|
|
|
* @return $this |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setDefault($default) { |
|
162
|
|
|
$this->default = $default; |
|
163
|
|
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* |
|
168
|
|
|
* @return float |
|
169
|
|
|
*/ |
|
170
|
|
|
public function getMaximum() { |
|
171
|
|
|
return $this->maximum; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* |
|
176
|
|
|
* @param float $maximum |
|
177
|
|
|
* @return $this |
|
178
|
|
|
*/ |
|
179
|
|
|
public function setMaximum($maximum) { |
|
180
|
|
|
$this->maximum = $maximum; |
|
181
|
|
|
return $this; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* |
|
186
|
|
|
* @return boolean |
|
187
|
|
|
*/ |
|
188
|
|
|
public function isExclusiveMaximum() { |
|
189
|
|
|
return $this->exclusiveMaximum; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* |
|
194
|
|
|
* @param boolean $exclusiveMaximum |
|
195
|
|
|
* @return $this |
|
196
|
|
|
*/ |
|
197
|
|
|
public function setExclusiveMaximum($exclusiveMaximum) { |
|
198
|
|
|
$this->exclusiveMaximum = $exclusiveMaximum; |
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* |
|
204
|
|
|
* @return float |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getMinimum() { |
|
207
|
|
|
return $this->minimum; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* |
|
212
|
|
|
* @param float $minimum |
|
213
|
|
|
* @return $this |
|
214
|
|
|
*/ |
|
215
|
|
|
public function setMinimum($minimum) { |
|
216
|
|
|
$this->minimum = $minimum; |
|
217
|
|
|
return $this; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* |
|
222
|
|
|
* @return boolean |
|
223
|
|
|
*/ |
|
224
|
|
|
public function isExclusiveMinimum() { |
|
225
|
|
|
return $this->exclusiveMinimum; |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* |
|
230
|
|
|
* @param boolean $exclusiveMinimum |
|
231
|
|
|
* @return $this |
|
232
|
|
|
*/ |
|
233
|
|
|
public function setExclusiveMinimum($exclusiveMinimum) { |
|
234
|
|
|
$this->exclusiveMinimum = $exclusiveMinimum; |
|
235
|
|
|
return $this; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* |
|
240
|
|
|
* @return int |
|
241
|
|
|
*/ |
|
242
|
|
|
public function getMaxLength() { |
|
243
|
|
|
return $this->maxLength; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* |
|
248
|
|
|
* @param int $maxLength |
|
249
|
|
|
* @return $this |
|
250
|
|
|
*/ |
|
251
|
|
|
public function setMaxLength($maxLength) { |
|
252
|
|
|
$this->maxLength = $maxLength; |
|
253
|
|
|
return $this; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* |
|
258
|
|
|
* @return int |
|
259
|
|
|
*/ |
|
260
|
|
|
public function getMinLength() { |
|
261
|
|
|
return $this->minLength; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* |
|
266
|
|
|
* @param int $minLength |
|
267
|
|
|
* @return $this |
|
268
|
|
|
*/ |
|
269
|
|
|
public function setMinLength($minLength) { |
|
270
|
|
|
$this->minLength = $minLength; |
|
271
|
|
|
return $this; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* |
|
276
|
|
|
* @return string |
|
277
|
|
|
*/ |
|
278
|
|
|
public function getPattern() { |
|
279
|
|
|
return $this->pattern; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* |
|
284
|
|
|
* @param string $pattern |
|
285
|
|
|
* @return $thi |
|
|
|
|
|
|
286
|
|
|
*/ |
|
287
|
|
|
public function setPattern($pattern) { |
|
288
|
|
|
$this->pattern = $pattern; |
|
289
|
|
|
return $this; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* |
|
294
|
|
|
* @return int |
|
295
|
|
|
*/ |
|
296
|
|
|
public function getMaxItems() { |
|
297
|
|
|
return $this->maxItems; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* |
|
302
|
|
|
* @param int $maxItems |
|
303
|
|
|
* @return $this |
|
304
|
|
|
*/ |
|
305
|
|
|
public function setMaxItems($maxItems) { |
|
306
|
|
|
$this->maxItems = $maxItems; |
|
307
|
|
|
return $this; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* |
|
312
|
|
|
* @return int |
|
313
|
|
|
*/ |
|
314
|
|
|
public function getMinItems() { |
|
315
|
|
|
return $this->minItems; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* |
|
320
|
|
|
* @param int $minItems |
|
321
|
|
|
* @return $this |
|
322
|
|
|
*/ |
|
323
|
|
|
public function setMinItems($minItems) { |
|
324
|
|
|
$this->minItems = $minItems; |
|
325
|
|
|
return $this; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* |
|
330
|
|
|
* @return boolean |
|
331
|
|
|
*/ |
|
332
|
|
|
public function hasUniqueItems() { |
|
333
|
|
|
return $this->uniqueItems; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* |
|
338
|
|
|
* @param boolean $uniqueItems |
|
339
|
|
|
* @return $this |
|
340
|
|
|
*/ |
|
341
|
|
|
public function setUniqueItems($uniqueItems) { |
|
342
|
|
|
$this->uniqueItems = $uniqueItems; |
|
343
|
|
|
return $this; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* |
|
348
|
|
|
* @return mixed |
|
349
|
|
|
*/ |
|
350
|
|
|
public function getEnum() { |
|
351
|
|
|
return $this->enum; |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
/** |
|
355
|
|
|
* |
|
356
|
|
|
* @param mixed $enum |
|
357
|
|
|
* @return $this |
|
358
|
|
|
*/ |
|
359
|
|
|
public function setEnum($enum) { |
|
360
|
|
|
$this->enum = $enum; |
|
361
|
|
|
return $this; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* |
|
366
|
|
|
* @return float |
|
367
|
|
|
*/ |
|
368
|
|
|
public function getMultipleOf() { |
|
369
|
|
|
return $this->multipleOf; |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* |
|
374
|
|
|
* @param float $multipleOf |
|
375
|
|
|
* @return $this |
|
376
|
|
|
*/ |
|
377
|
|
|
public function setMultipleOf($multipleOf) { |
|
378
|
|
|
$this->multipleOf = $multipleOf; |
|
379
|
|
|
return $this; |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
|
|
384
|
|
|
|
|
385
|
|
|
} |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.