@@ -5,129 +5,129 @@ discard block |
||
5 | 5 | class PreprocessorTest extends \SwaggerGen_TestCase |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::__construct |
|
10 | - */ |
|
11 | - public function testConstructor_Empty() |
|
12 | - { |
|
13 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
14 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
15 | - } |
|
16 | - |
|
17 | - /** |
|
18 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
19 | - */ |
|
20 | - public function testPreprocess_Ifdef_NotDefined() |
|
21 | - { |
|
22 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
23 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
24 | - $out = $object->preprocess(' |
|
8 | + /** |
|
9 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::__construct |
|
10 | + */ |
|
11 | + public function testConstructor_Empty() |
|
12 | + { |
|
13 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
14 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
15 | + } |
|
16 | + |
|
17 | + /** |
|
18 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
19 | + */ |
|
20 | + public function testPreprocess_Ifdef_NotDefined() |
|
21 | + { |
|
22 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
23 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
24 | + $out = $object->preprocess(' |
|
25 | 25 | ifdef test |
26 | 26 | whatever |
27 | 27 | endif |
28 | 28 | '); |
29 | 29 | |
30 | - $this->assertEquals(' |
|
30 | + $this->assertEquals(' |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | 34 | ', $out); |
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
39 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
40 | - */ |
|
41 | - public function testPreprocess_Ifdef_Defined() |
|
42 | - { |
|
43 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
44 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
45 | - $object->define('test'); |
|
46 | - $out = $object->preprocess(' |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
39 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
40 | + */ |
|
41 | + public function testPreprocess_Ifdef_Defined() |
|
42 | + { |
|
43 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
44 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
45 | + $object->define('test'); |
|
46 | + $out = $object->preprocess(' |
|
47 | 47 | ifdef test |
48 | 48 | whatever |
49 | 49 | endif |
50 | 50 | '); |
51 | 51 | |
52 | - $this->assertEquals(' |
|
52 | + $this->assertEquals(' |
|
53 | 53 | |
54 | 54 | whatever |
55 | 55 | |
56 | 56 | ', $out); |
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
61 | - */ |
|
62 | - public function testPreprocess_Ifndef_NotDefined() |
|
63 | - { |
|
64 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
65 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
66 | - $out = $object->preprocess(' |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
61 | + */ |
|
62 | + public function testPreprocess_Ifndef_NotDefined() |
|
63 | + { |
|
64 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
65 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
66 | + $out = $object->preprocess(' |
|
67 | 67 | ifndef test |
68 | 68 | whatever |
69 | 69 | endif |
70 | 70 | '); |
71 | 71 | |
72 | - $this->assertEquals(' |
|
72 | + $this->assertEquals(' |
|
73 | 73 | |
74 | 74 | whatever |
75 | 75 | |
76 | 76 | ', $out); |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
81 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
82 | - */ |
|
83 | - public function testPreprocess_Ifndef_Defined() |
|
84 | - { |
|
85 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
86 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
87 | - $object->define('test'); |
|
88 | - $out = $object->preprocess(' |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
81 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
82 | + */ |
|
83 | + public function testPreprocess_Ifndef_Defined() |
|
84 | + { |
|
85 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
86 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
87 | + $object->define('test'); |
|
88 | + $out = $object->preprocess(' |
|
89 | 89 | ifndef test |
90 | 90 | whatever |
91 | 91 | endif |
92 | 92 | '); |
93 | 93 | |
94 | - $this->assertEquals(' |
|
94 | + $this->assertEquals(' |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | 98 | ', $out); |
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
103 | - */ |
|
104 | - public function testPreprocess_Define() |
|
105 | - { |
|
106 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
107 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
108 | - $out = $object->preprocess(' |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
103 | + */ |
|
104 | + public function testPreprocess_Define() |
|
105 | + { |
|
106 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
107 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
108 | + $out = $object->preprocess(' |
|
109 | 109 | define test |
110 | 110 | ifndef test |
111 | 111 | whatever |
112 | 112 | endif |
113 | 113 | '); |
114 | 114 | |
115 | - $this->assertEquals(' |
|
115 | + $this->assertEquals(' |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | 119 | |
120 | 120 | ', $out); |
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
125 | - */ |
|
126 | - public function testPreprocess_Undef() |
|
127 | - { |
|
128 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
129 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
130 | - $out = $object->preprocess(' |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
125 | + */ |
|
126 | + public function testPreprocess_Undef() |
|
127 | + { |
|
128 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
129 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
130 | + $out = $object->preprocess(' |
|
131 | 131 | define test |
132 | 132 | undef test |
133 | 133 | ifdef test |
@@ -135,133 +135,133 @@ discard block |
||
135 | 135 | endif |
136 | 136 | '); |
137 | 137 | |
138 | - $this->assertEquals(' |
|
138 | + $this->assertEquals(' |
|
139 | 139 | |
140 | 140 | |
141 | 141 | |
142 | 142 | |
143 | 143 | |
144 | 144 | ', $out); |
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
149 | - */ |
|
150 | - public function testPreprocess_If_NotDefined() |
|
151 | - { |
|
152 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
153 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
154 | - $out = $object->preprocess(' |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
149 | + */ |
|
150 | + public function testPreprocess_If_NotDefined() |
|
151 | + { |
|
152 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
153 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
154 | + $out = $object->preprocess(' |
|
155 | 155 | if test red |
156 | 156 | whatever |
157 | 157 | endif |
158 | 158 | '); |
159 | 159 | |
160 | - $this->assertEquals(' |
|
160 | + $this->assertEquals(' |
|
161 | 161 | |
162 | 162 | |
163 | 163 | |
164 | 164 | ', $out); |
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
169 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
170 | - */ |
|
171 | - public function testPreprocess_If_AnyValue() |
|
172 | - { |
|
173 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
174 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
175 | - $object->define('test', 'green'); |
|
176 | - $out = $object->preprocess(' |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
169 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
170 | + */ |
|
171 | + public function testPreprocess_If_AnyValue() |
|
172 | + { |
|
173 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
174 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
175 | + $object->define('test', 'green'); |
|
176 | + $out = $object->preprocess(' |
|
177 | 177 | if test |
178 | 178 | whatever |
179 | 179 | endif |
180 | 180 | '); |
181 | 181 | |
182 | - $this->assertEquals(' |
|
182 | + $this->assertEquals(' |
|
183 | 183 | |
184 | 184 | whatever |
185 | 185 | |
186 | 186 | ', $out); |
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
191 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
192 | - */ |
|
193 | - public function testPreprocess_If_NoValue() |
|
194 | - { |
|
195 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
196 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
197 | - $object->define('test'); |
|
198 | - $out = $object->preprocess(' |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
191 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
192 | + */ |
|
193 | + public function testPreprocess_If_NoValue() |
|
194 | + { |
|
195 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
196 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
197 | + $object->define('test'); |
|
198 | + $out = $object->preprocess(' |
|
199 | 199 | if test red |
200 | 200 | whatever |
201 | 201 | endif |
202 | 202 | '); |
203 | 203 | |
204 | - $this->assertEquals(' |
|
204 | + $this->assertEquals(' |
|
205 | 205 | |
206 | 206 | |
207 | 207 | |
208 | 208 | ', $out); |
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
213 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
214 | - */ |
|
215 | - public function testPreprocess_If_Mismatch() |
|
216 | - { |
|
217 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
218 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
219 | - $object->define('test', 'green'); |
|
220 | - $out = $object->preprocess(' |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
213 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
214 | + */ |
|
215 | + public function testPreprocess_If_Mismatch() |
|
216 | + { |
|
217 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
218 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
219 | + $object->define('test', 'green'); |
|
220 | + $out = $object->preprocess(' |
|
221 | 221 | if test red |
222 | 222 | whatever |
223 | 223 | endif |
224 | 224 | '); |
225 | 225 | |
226 | - $this->assertEquals(' |
|
226 | + $this->assertEquals(' |
|
227 | 227 | |
228 | 228 | |
229 | 229 | |
230 | 230 | ', $out); |
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
235 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
236 | - */ |
|
237 | - public function testPreprocess_If_Match() |
|
238 | - { |
|
239 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
240 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
241 | - $object->define('test', 'red'); |
|
242 | - $out = $object->preprocess(' |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
235 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
236 | + */ |
|
237 | + public function testPreprocess_If_Match() |
|
238 | + { |
|
239 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
240 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
241 | + $object->define('test', 'red'); |
|
242 | + $out = $object->preprocess(' |
|
243 | 243 | if test red |
244 | 244 | whatever |
245 | 245 | endif |
246 | 246 | '); |
247 | 247 | |
248 | - $this->assertEquals(' |
|
248 | + $this->assertEquals(' |
|
249 | 249 | |
250 | 250 | whatever |
251 | 251 | |
252 | 252 | ', $out); |
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
257 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
258 | - */ |
|
259 | - public function testPreprocess_Else_Match() |
|
260 | - { |
|
261 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
262 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
263 | - $object->define('test', 'blue'); |
|
264 | - $out = $object->preprocess(' |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
257 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
258 | + */ |
|
259 | + public function testPreprocess_Else_Match() |
|
260 | + { |
|
261 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
262 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
263 | + $object->define('test', 'blue'); |
|
264 | + $out = $object->preprocess(' |
|
265 | 265 | if test red |
266 | 266 | whatever |
267 | 267 | else |
@@ -269,25 +269,25 @@ discard block |
||
269 | 269 | endif |
270 | 270 | '); |
271 | 271 | |
272 | - $this->assertEquals(' |
|
272 | + $this->assertEquals(' |
|
273 | 273 | |
274 | 274 | |
275 | 275 | |
276 | 276 | otherwise |
277 | 277 | |
278 | 278 | ', $out); |
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
283 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
284 | - */ |
|
285 | - public function testPreprocess_Elif_Match() |
|
286 | - { |
|
287 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
288 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
289 | - $object->define('test', 'blue'); |
|
290 | - $out = $object->preprocess(' |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
283 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
284 | + */ |
|
285 | + public function testPreprocess_Elif_Match() |
|
286 | + { |
|
287 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
288 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
289 | + $object->define('test', 'blue'); |
|
290 | + $out = $object->preprocess(' |
|
291 | 291 | if test red |
292 | 292 | whatever |
293 | 293 | elif test green |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | endif |
298 | 298 | '); |
299 | 299 | |
300 | - $this->assertEquals(' |
|
300 | + $this->assertEquals(' |
|
301 | 301 | |
302 | 302 | |
303 | 303 | |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | otherwise |
307 | 307 | |
308 | 308 | ', $out); |
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
313 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
314 | - */ |
|
315 | - public function testPreprocess_Elif_NoValue() |
|
316 | - { |
|
317 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
318 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
319 | - $object->define('test', 'blue'); |
|
320 | - $out = $object->preprocess(' |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
313 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
314 | + */ |
|
315 | + public function testPreprocess_Elif_NoValue() |
|
316 | + { |
|
317 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
318 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
319 | + $object->define('test', 'blue'); |
|
320 | + $out = $object->preprocess(' |
|
321 | 321 | if test red |
322 | 322 | whatever |
323 | 323 | elif test green |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | endif |
328 | 328 | '); |
329 | 329 | |
330 | - $this->assertEquals(' |
|
330 | + $this->assertEquals(' |
|
331 | 331 | |
332 | 332 | |
333 | 333 | |
@@ -336,76 +336,76 @@ discard block |
||
336 | 336 | otherwise |
337 | 337 | |
338 | 338 | ', $out); |
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
343 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::undefine |
|
344 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
345 | - */ |
|
346 | - public function testPreprocess_Undefine() |
|
347 | - { |
|
348 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
349 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
350 | - $object->define('test'); |
|
351 | - $object->undefine('test'); |
|
352 | - $out = $object->preprocess(' |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
343 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::undefine |
|
344 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
345 | + */ |
|
346 | + public function testPreprocess_Undefine() |
|
347 | + { |
|
348 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
349 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
350 | + $object->define('test'); |
|
351 | + $object->undefine('test'); |
|
352 | + $out = $object->preprocess(' |
|
353 | 353 | ifdef test |
354 | 354 | whatever |
355 | 355 | endif |
356 | 356 | '); |
357 | 357 | |
358 | - $this->assertEquals(' |
|
358 | + $this->assertEquals(' |
|
359 | 359 | |
360 | 360 | |
361 | 361 | |
362 | 362 | ', $out); |
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
367 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::resetDefines |
|
368 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
369 | - */ |
|
370 | - public function testPreprocess_ResetDefines() |
|
371 | - { |
|
372 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
373 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
374 | - $object->define('test'); |
|
375 | - $object->resetDefines(); |
|
376 | - $out = $object->preprocess(' |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::define |
|
367 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::resetDefines |
|
368 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
369 | + */ |
|
370 | + public function testPreprocess_ResetDefines() |
|
371 | + { |
|
372 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
373 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
374 | + $object->define('test'); |
|
375 | + $object->resetDefines(); |
|
376 | + $out = $object->preprocess(' |
|
377 | 377 | ifdef test |
378 | 378 | whatever |
379 | 379 | endif |
380 | 380 | '); |
381 | 381 | |
382 | - $this->assertEquals(' |
|
382 | + $this->assertEquals(' |
|
383 | 383 | |
384 | 384 | |
385 | 385 | |
386 | 386 | ', $out); |
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::addDefines |
|
391 | - * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
392 | - */ |
|
393 | - public function testPreprocess_AddDefines() |
|
394 | - { |
|
395 | - $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
396 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
397 | - $object->addDefines(['test' => true]); |
|
398 | - $out = $object->preprocess(' |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::addDefines |
|
391 | + * @covers \SwaggerGen\Parser\Text\Preprocessor::preprocess |
|
392 | + */ |
|
393 | + public function testPreprocess_AddDefines() |
|
394 | + { |
|
395 | + $object = new \SwaggerGen\Parser\Text\Preprocessor(); |
|
396 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Preprocessor', $object); |
|
397 | + $object->addDefines(['test' => true]); |
|
398 | + $out = $object->preprocess(' |
|
399 | 399 | ifdef test |
400 | 400 | whatever |
401 | 401 | endif |
402 | 402 | '); |
403 | 403 | |
404 | - $this->assertEquals(' |
|
404 | + $this->assertEquals(' |
|
405 | 405 | |
406 | 406 | whatever |
407 | 407 | |
408 | 408 | ', $out); |
409 | - } |
|
409 | + } |
|
410 | 410 | |
411 | 411 | } |
@@ -15,28 +15,28 @@ |
||
15 | 15 | class StatementException extends \Exception |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var Statement |
|
20 | - */ |
|
21 | - private $statement; |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * @param string $message |
|
26 | - * @param int $code |
|
27 | - * @param Throwable $previous |
|
28 | - * @param Statement $statement |
|
29 | - */ |
|
30 | - public function __construct($message = "", $code = 0, $previous = null, $statement = null) |
|
31 | - { |
|
32 | - $this->statement = $statement; |
|
33 | - |
|
34 | - parent::__construct($message, $code, $previous); |
|
35 | - } |
|
36 | - |
|
37 | - public function getStatement() |
|
38 | - { |
|
39 | - return $this->statement; |
|
40 | - } |
|
18 | + /** |
|
19 | + * @var Statement |
|
20 | + */ |
|
21 | + private $statement; |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * @param string $message |
|
26 | + * @param int $code |
|
27 | + * @param Throwable $previous |
|
28 | + * @param Statement $statement |
|
29 | + */ |
|
30 | + public function __construct($message = "", $code = 0, $previous = null, $statement = null) |
|
31 | + { |
|
32 | + $this->statement = $statement; |
|
33 | + |
|
34 | + parent::__construct($message, $code, $previous); |
|
35 | + } |
|
36 | + |
|
37 | + public function getStatement() |
|
38 | + { |
|
39 | + return $this->statement; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -14,61 +14,61 @@ |
||
14 | 14 | class Statement |
15 | 15 | { |
16 | 16 | |
17 | - private $command; |
|
18 | - private $data; |
|
19 | - private $file; |
|
20 | - private $line; |
|
17 | + private $command; |
|
18 | + private $data; |
|
19 | + private $file; |
|
20 | + private $line; |
|
21 | 21 | |
22 | - public function __construct($command, $data = null, $file = null, $line = null) |
|
23 | - { |
|
24 | - $this->command = $command; |
|
25 | - $this->data = $data; |
|
26 | - $this->file = $file; |
|
27 | - $this->line = $line; |
|
28 | - } |
|
22 | + public function __construct($command, $data = null, $file = null, $line = null) |
|
23 | + { |
|
24 | + $this->command = $command; |
|
25 | + $this->data = $data; |
|
26 | + $this->file = $file; |
|
27 | + $this->line = $line; |
|
28 | + } |
|
29 | 29 | |
30 | - public function __toString() |
|
31 | - { |
|
32 | - $message = "Command '{$this->command}'"; |
|
33 | - $message .= $this->data ? " with data '{$this->data}'" : ' without data'; |
|
34 | - $message .= $this->file ? " from static text" : " in file '{$this->file}' on line {$this->line}"; |
|
35 | - return $message; |
|
36 | - } |
|
30 | + public function __toString() |
|
31 | + { |
|
32 | + $message = "Command '{$this->command}'"; |
|
33 | + $message .= $this->data ? " with data '{$this->data}'" : ' without data'; |
|
34 | + $message .= $this->file ? " from static text" : " in file '{$this->file}' on line {$this->line}"; |
|
35 | + return $message; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the command part of this statement |
|
40 | - * @return string single word, without spaces |
|
41 | - */ |
|
42 | - public function getCommand() |
|
43 | - { |
|
44 | - return $this->command; |
|
45 | - } |
|
38 | + /** |
|
39 | + * Get the command part of this statement |
|
40 | + * @return string single word, without spaces |
|
41 | + */ |
|
42 | + public function getCommand() |
|
43 | + { |
|
44 | + return $this->command; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the data of this statement |
|
49 | - * @return string may contain spaces |
|
50 | - */ |
|
51 | - public function getData() |
|
52 | - { |
|
53 | - return $this->data; |
|
54 | - } |
|
47 | + /** |
|
48 | + * Get the data of this statement |
|
49 | + * @return string may contain spaces |
|
50 | + */ |
|
51 | + public function getData() |
|
52 | + { |
|
53 | + return $this->data; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get the file (if available) where this statement was parsed from |
|
58 | - * @return string|null the full filename or null of from static text |
|
59 | - */ |
|
60 | - public function getFile() |
|
61 | - { |
|
62 | - return $this->file; |
|
63 | - } |
|
56 | + /** |
|
57 | + * Get the file (if available) where this statement was parsed from |
|
58 | + * @return string|null the full filename or null of from static text |
|
59 | + */ |
|
60 | + public function getFile() |
|
61 | + { |
|
62 | + return $this->file; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Get the line number where this statement was found |
|
67 | - * @return int|null the line number |
|
68 | - */ |
|
69 | - public function getLine() |
|
70 | - { |
|
71 | - return $this->line; |
|
72 | - } |
|
65 | + /** |
|
66 | + * Get the line number where this statement was found |
|
67 | + * @return int|null the line number |
|
68 | + */ |
|
69 | + public function getLine() |
|
70 | + { |
|
71 | + return $this->line; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | $this->Type = new $class($this, $definition); |
116 | 116 | } elseif (isset(self::$classTypes[$format])) { |
117 | 117 | $type = self::$classTypes[$format]; |
118 | - $class = "\\SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
118 | + $class = "\\SwaggerGen\\Swagger\\Type\\{$type}type"; |
|
119 | 119 | $this->Type = new $class($this, $definition); |
120 | 120 | } else { |
121 | 121 | throw new Exception("Type format not recognized: '{$format}'"); |
@@ -15,147 +15,147 @@ |
||
15 | 15 | class Parameter extends AbstractObject implements IParameter |
16 | 16 | { |
17 | 17 | |
18 | - private static $classTypes = array( |
|
19 | - 'integer' => 'Integer', |
|
20 | - 'int' => 'Integer', |
|
21 | - 'int32' => 'Integer', |
|
22 | - 'int64' => 'Integer', |
|
23 | - 'long' => 'Integer', |
|
24 | - 'float' => 'Number', |
|
25 | - 'double' => 'Number', |
|
26 | - 'string' => 'String', |
|
27 | - 'byte' => 'String', |
|
28 | - 'binary' => 'String', |
|
29 | - 'password' => 'String', |
|
30 | - 'enum' => 'String', |
|
31 | - 'uuid' => 'StringUuid', |
|
32 | - 'boolean' => 'Boolean', |
|
33 | - 'bool' => 'Boolean', |
|
34 | - 'array' => 'Array', |
|
35 | - 'csv' => 'Array', |
|
36 | - 'ssv' => 'Array', |
|
37 | - 'tsv' => 'Array', |
|
38 | - 'pipes' => 'Array', |
|
39 | - 'multi' => 'Array', |
|
40 | - 'date' => 'Date', |
|
41 | - 'datetime' => 'Date', |
|
42 | - 'date-time' => 'Date', |
|
43 | - 'file' => 'File', |
|
44 | - ); |
|
45 | - private $name = ''; |
|
46 | - private $in; |
|
47 | - private $description; |
|
48 | - private $required = false; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var Type\AbstractType |
|
52 | - */ |
|
53 | - private $Type; |
|
54 | - |
|
55 | - /** |
|
56 | - * Returns true if the "multi" array collectionFormat is allowed for this |
|
57 | - * parameter. |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isMulti(): bool |
|
61 | - { |
|
62 | - return in_array($this->in, array('query', 'form')); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Return true if the parameter is of type 'formData' |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function isForm(): bool |
|
70 | - { |
|
71 | - return $this->in === 'form'; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @throws Exception |
|
76 | - */ |
|
77 | - public function __construct(AbstractObject $parent, $in, $data, $required = false) |
|
78 | - { |
|
79 | - parent::__construct($parent); |
|
80 | - |
|
81 | - if ($in !== 'path' && $in !== 'form' && $in !== 'query' && $in !== 'header') { |
|
82 | - throw new Exception("Invalid in for parameter: '{$in}'"); |
|
83 | - } |
|
84 | - $this->in = $in; |
|
85 | - |
|
86 | - $definition = self::wordShift($data); |
|
87 | - if (empty($definition)) { |
|
88 | - throw new Exception('No type definition for parameter'); |
|
89 | - } |
|
90 | - |
|
91 | - $name = self::wordShift($data); |
|
92 | - if (empty($name)) { |
|
93 | - throw new Exception('No name for parameter'); |
|
94 | - } |
|
95 | - |
|
96 | - $this->name = $name; |
|
97 | - |
|
98 | - $this->description = $data; |
|
99 | - $this->required = (bool)$required; |
|
100 | - |
|
101 | - // Parse regex |
|
102 | - $match = array(); |
|
103 | - if (preg_match('/^([a-z][a-z0-9]*)/i', $definition, $match) === 1) { |
|
104 | - $format = strtolower($match[1]); |
|
105 | - } elseif (preg_match('/^(\[)(?:.*?)\]$/', $definition, $match) === 1) { |
|
106 | - $format = 'array'; |
|
107 | - } elseif (preg_match('/^(\{)(?:.*?)\}$/', $definition, $match) === 1) { |
|
108 | - $format = 'object'; |
|
109 | - } else { |
|
110 | - throw new Exception('Unparseable parameter format definition: \'' . $definition . '\''); |
|
111 | - } |
|
112 | - |
|
113 | - if ($this->getTypeRegistry()->has($format)) { |
|
114 | - $class = $this->getTypeRegistry()->get($format); |
|
115 | - $this->Type = new $class($this, $definition); |
|
116 | - } elseif (isset(self::$classTypes[$format])) { |
|
117 | - $type = self::$classTypes[$format]; |
|
118 | - $class = "\\SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
119 | - $this->Type = new $class($this, $definition); |
|
120 | - } else { |
|
121 | - throw new Exception("Type format not recognized: '{$format}'"); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $command |
|
127 | - * @param string $data |
|
128 | - * @return AbstractObject|boolean |
|
129 | - * @throws Exception |
|
130 | - */ |
|
131 | - public function handleCommand($command, $data = null) |
|
132 | - { |
|
133 | - // Pass through to Type |
|
134 | - if ($this->Type && $this->Type->handleCommand($command, $data)) { |
|
135 | - return $this; |
|
136 | - } |
|
137 | - |
|
138 | - return parent::handleCommand($command, $data); |
|
139 | - } |
|
140 | - |
|
141 | - public function toArray(): array |
|
142 | - { |
|
143 | - return self::arrayFilterNull(array_merge(array( |
|
144 | - 'name' => $this->name, |
|
145 | - 'in' => $this->in === 'form' ? 'formData' : $this->in, |
|
146 | - 'description' => empty($this->description) ? null : $this->description, |
|
147 | - 'required' => $this->in === 'path' || $this->required ? true : null, |
|
148 | - ), $this->Type->toArray(), parent::toArray())); |
|
149 | - } |
|
150 | - |
|
151 | - public function __toString() |
|
152 | - { |
|
153 | - return __CLASS__ . " {$this->name} {$this->in}"; |
|
154 | - } |
|
155 | - |
|
156 | - public function getName() |
|
157 | - { |
|
158 | - return $this->name; |
|
159 | - } |
|
18 | + private static $classTypes = array( |
|
19 | + 'integer' => 'Integer', |
|
20 | + 'int' => 'Integer', |
|
21 | + 'int32' => 'Integer', |
|
22 | + 'int64' => 'Integer', |
|
23 | + 'long' => 'Integer', |
|
24 | + 'float' => 'Number', |
|
25 | + 'double' => 'Number', |
|
26 | + 'string' => 'String', |
|
27 | + 'byte' => 'String', |
|
28 | + 'binary' => 'String', |
|
29 | + 'password' => 'String', |
|
30 | + 'enum' => 'String', |
|
31 | + 'uuid' => 'StringUuid', |
|
32 | + 'boolean' => 'Boolean', |
|
33 | + 'bool' => 'Boolean', |
|
34 | + 'array' => 'Array', |
|
35 | + 'csv' => 'Array', |
|
36 | + 'ssv' => 'Array', |
|
37 | + 'tsv' => 'Array', |
|
38 | + 'pipes' => 'Array', |
|
39 | + 'multi' => 'Array', |
|
40 | + 'date' => 'Date', |
|
41 | + 'datetime' => 'Date', |
|
42 | + 'date-time' => 'Date', |
|
43 | + 'file' => 'File', |
|
44 | + ); |
|
45 | + private $name = ''; |
|
46 | + private $in; |
|
47 | + private $description; |
|
48 | + private $required = false; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var Type\AbstractType |
|
52 | + */ |
|
53 | + private $Type; |
|
54 | + |
|
55 | + /** |
|
56 | + * Returns true if the "multi" array collectionFormat is allowed for this |
|
57 | + * parameter. |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isMulti(): bool |
|
61 | + { |
|
62 | + return in_array($this->in, array('query', 'form')); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Return true if the parameter is of type 'formData' |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function isForm(): bool |
|
70 | + { |
|
71 | + return $this->in === 'form'; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @throws Exception |
|
76 | + */ |
|
77 | + public function __construct(AbstractObject $parent, $in, $data, $required = false) |
|
78 | + { |
|
79 | + parent::__construct($parent); |
|
80 | + |
|
81 | + if ($in !== 'path' && $in !== 'form' && $in !== 'query' && $in !== 'header') { |
|
82 | + throw new Exception("Invalid in for parameter: '{$in}'"); |
|
83 | + } |
|
84 | + $this->in = $in; |
|
85 | + |
|
86 | + $definition = self::wordShift($data); |
|
87 | + if (empty($definition)) { |
|
88 | + throw new Exception('No type definition for parameter'); |
|
89 | + } |
|
90 | + |
|
91 | + $name = self::wordShift($data); |
|
92 | + if (empty($name)) { |
|
93 | + throw new Exception('No name for parameter'); |
|
94 | + } |
|
95 | + |
|
96 | + $this->name = $name; |
|
97 | + |
|
98 | + $this->description = $data; |
|
99 | + $this->required = (bool)$required; |
|
100 | + |
|
101 | + // Parse regex |
|
102 | + $match = array(); |
|
103 | + if (preg_match('/^([a-z][a-z0-9]*)/i', $definition, $match) === 1) { |
|
104 | + $format = strtolower($match[1]); |
|
105 | + } elseif (preg_match('/^(\[)(?:.*?)\]$/', $definition, $match) === 1) { |
|
106 | + $format = 'array'; |
|
107 | + } elseif (preg_match('/^(\{)(?:.*?)\}$/', $definition, $match) === 1) { |
|
108 | + $format = 'object'; |
|
109 | + } else { |
|
110 | + throw new Exception('Unparseable parameter format definition: \'' . $definition . '\''); |
|
111 | + } |
|
112 | + |
|
113 | + if ($this->getTypeRegistry()->has($format)) { |
|
114 | + $class = $this->getTypeRegistry()->get($format); |
|
115 | + $this->Type = new $class($this, $definition); |
|
116 | + } elseif (isset(self::$classTypes[$format])) { |
|
117 | + $type = self::$classTypes[$format]; |
|
118 | + $class = "\\SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
119 | + $this->Type = new $class($this, $definition); |
|
120 | + } else { |
|
121 | + throw new Exception("Type format not recognized: '{$format}'"); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $command |
|
127 | + * @param string $data |
|
128 | + * @return AbstractObject|boolean |
|
129 | + * @throws Exception |
|
130 | + */ |
|
131 | + public function handleCommand($command, $data = null) |
|
132 | + { |
|
133 | + // Pass through to Type |
|
134 | + if ($this->Type && $this->Type->handleCommand($command, $data)) { |
|
135 | + return $this; |
|
136 | + } |
|
137 | + |
|
138 | + return parent::handleCommand($command, $data); |
|
139 | + } |
|
140 | + |
|
141 | + public function toArray(): array |
|
142 | + { |
|
143 | + return self::arrayFilterNull(array_merge(array( |
|
144 | + 'name' => $this->name, |
|
145 | + 'in' => $this->in === 'form' ? 'formData' : $this->in, |
|
146 | + 'description' => empty($this->description) ? null : $this->description, |
|
147 | + 'required' => $this->in === 'path' || $this->required ? true : null, |
|
148 | + ), $this->Type->toArray(), parent::toArray())); |
|
149 | + } |
|
150 | + |
|
151 | + public function __toString() |
|
152 | + { |
|
153 | + return __CLASS__ . " {$this->name} {$this->in}"; |
|
154 | + } |
|
155 | + |
|
156 | + public function getName() |
|
157 | + { |
|
158 | + return $this->name; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | $this->name = $name; |
97 | 97 | |
98 | 98 | $this->description = $data; |
99 | - $this->required = (bool)$required; |
|
99 | + $this->required = (bool) $required; |
|
100 | 100 | |
101 | 101 | // Parse regex |
102 | 102 | $match = array(); |
@@ -14,9 +14,9 @@ |
||
14 | 14 | class Error extends Response |
15 | 15 | { |
16 | 16 | |
17 | - public function __construct(AbstractObject $parent, $code, $description = null) |
|
18 | - { |
|
19 | - parent::__construct($parent, $code, null, $description); |
|
20 | - } |
|
17 | + public function __construct(AbstractObject $parent, $code, $description = null) |
|
18 | + { |
|
19 | + parent::__construct($parent, $code, null, $description); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | $this->description = $data; |
48 | - $this->required = (bool)$required; |
|
48 | + $this->required = (bool) $required; |
|
49 | 49 | |
50 | 50 | $this->schema = new Schema($this, $type); |
51 | 51 | } |
@@ -15,77 +15,77 @@ |
||
15 | 15 | class BodyParameter extends AbstractObject implements IParameter |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var string|boolean |
|
20 | - */ |
|
21 | - private $name = ''; |
|
22 | - private $description; |
|
23 | - private $required = false; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var Schema |
|
27 | - */ |
|
28 | - private $schema; |
|
29 | - |
|
30 | - /** |
|
31 | - * @throws Exception |
|
32 | - */ |
|
33 | - public function __construct(AbstractObject $parent, $data, $required = false) |
|
34 | - { |
|
35 | - parent::__construct($parent); |
|
36 | - |
|
37 | - $type = self::wordShift($data); |
|
38 | - if (empty($type)) { |
|
39 | - throw new Exception('No type definition for body parameter'); |
|
40 | - } |
|
41 | - |
|
42 | - $this->name = self::wordShift($data); |
|
43 | - if (empty($this->name)) { |
|
44 | - throw new Exception('No name for body parameter'); |
|
45 | - } |
|
46 | - |
|
47 | - $this->description = $data; |
|
48 | - $this->required = (bool)$required; |
|
49 | - |
|
50 | - $this->schema = new Schema($this, $type); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $command |
|
55 | - * @param string $data |
|
56 | - * @return AbstractObject|boolean |
|
57 | - * @throws Exception |
|
58 | - */ |
|
59 | - public function handleCommand($command, $data = null) |
|
60 | - { |
|
61 | - // Pass through to Type |
|
62 | - $return = $this->schema->handleCommand($command, $data); |
|
63 | - if ($return) { |
|
64 | - return $return; |
|
65 | - } |
|
66 | - |
|
67 | - return parent::handleCommand($command, $data); |
|
68 | - } |
|
69 | - |
|
70 | - public function toArray(): array |
|
71 | - { |
|
72 | - return self::arrayFilterNull(array_merge(array( |
|
73 | - 'name' => $this->name, |
|
74 | - 'in' => 'body', |
|
75 | - 'description' => empty($this->description) ? null : $this->description, |
|
76 | - 'required' => $this->required ? true : null, |
|
77 | - 'schema' => $this->schema->toArray(), |
|
78 | - ), parent::toArray())); |
|
79 | - } |
|
80 | - |
|
81 | - public function __toString() |
|
82 | - { |
|
83 | - return __CLASS__ . ' ' . $this->name; |
|
84 | - } |
|
85 | - |
|
86 | - public function getName() |
|
87 | - { |
|
88 | - return $this->name; |
|
89 | - } |
|
18 | + /** |
|
19 | + * @var string|boolean |
|
20 | + */ |
|
21 | + private $name = ''; |
|
22 | + private $description; |
|
23 | + private $required = false; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var Schema |
|
27 | + */ |
|
28 | + private $schema; |
|
29 | + |
|
30 | + /** |
|
31 | + * @throws Exception |
|
32 | + */ |
|
33 | + public function __construct(AbstractObject $parent, $data, $required = false) |
|
34 | + { |
|
35 | + parent::__construct($parent); |
|
36 | + |
|
37 | + $type = self::wordShift($data); |
|
38 | + if (empty($type)) { |
|
39 | + throw new Exception('No type definition for body parameter'); |
|
40 | + } |
|
41 | + |
|
42 | + $this->name = self::wordShift($data); |
|
43 | + if (empty($this->name)) { |
|
44 | + throw new Exception('No name for body parameter'); |
|
45 | + } |
|
46 | + |
|
47 | + $this->description = $data; |
|
48 | + $this->required = (bool)$required; |
|
49 | + |
|
50 | + $this->schema = new Schema($this, $type); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $command |
|
55 | + * @param string $data |
|
56 | + * @return AbstractObject|boolean |
|
57 | + * @throws Exception |
|
58 | + */ |
|
59 | + public function handleCommand($command, $data = null) |
|
60 | + { |
|
61 | + // Pass through to Type |
|
62 | + $return = $this->schema->handleCommand($command, $data); |
|
63 | + if ($return) { |
|
64 | + return $return; |
|
65 | + } |
|
66 | + |
|
67 | + return parent::handleCommand($command, $data); |
|
68 | + } |
|
69 | + |
|
70 | + public function toArray(): array |
|
71 | + { |
|
72 | + return self::arrayFilterNull(array_merge(array( |
|
73 | + 'name' => $this->name, |
|
74 | + 'in' => 'body', |
|
75 | + 'description' => empty($this->description) ? null : $this->description, |
|
76 | + 'required' => $this->required ? true : null, |
|
77 | + 'schema' => $this->schema->toArray(), |
|
78 | + ), parent::toArray())); |
|
79 | + } |
|
80 | + |
|
81 | + public function __toString() |
|
82 | + { |
|
83 | + return __CLASS__ . ' ' . $this->name; |
|
84 | + } |
|
85 | + |
|
86 | + public function getName() |
|
87 | + { |
|
88 | + return $this->name; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
@@ -13,5 +13,5 @@ |
||
13 | 13 | interface IParameter |
14 | 14 | { |
15 | 15 | |
16 | - public function getName(); |
|
16 | + public function getName(); |
|
17 | 17 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $consumes = $this->getSwagger()->getConsumes(); |
41 | 41 | } |
42 | 42 | |
43 | - $valid_consumes = ((int)in_array('multipart/form-data', $consumes)) + ((int)in_array('application/x-www-form-urlencoded', $consumes)); |
|
43 | + $valid_consumes = ((int) in_array('multipart/form-data', $consumes)) + ((int) in_array('application/x-www-form-urlencoded', $consumes)); |
|
44 | 44 | if (empty($consumes) || $valid_consumes !== count($consumes)) { |
45 | 45 | throw new Exception("File type '{$definition}' without valid consume"); |
46 | 46 | } |
@@ -17,45 +17,45 @@ |
||
17 | 17 | class FileType extends AbstractType |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @throws Exception |
|
22 | - */ |
|
23 | - protected function parseDefinition($definition) |
|
24 | - { |
|
25 | - $type = strtolower($definition); |
|
26 | - |
|
27 | - if ($type !== 'file') { |
|
28 | - throw new Exception("Not a file: '{$definition}'"); |
|
29 | - } |
|
30 | - |
|
31 | - $parent = $this->getParent(); |
|
32 | - if (!($parent instanceof Parameter) || !$parent->isForm()) { |
|
33 | - throw new Exception("File type '{$definition}' only allowed on form parameter"); |
|
34 | - } |
|
35 | - |
|
36 | - /** @var Operation $parentOperation */ |
|
37 | - $parentOperation = $this->getParentClass(Operation::class); |
|
38 | - $consumes = $parentOperation->getConsumes(); |
|
39 | - if (empty($consumes)) { |
|
40 | - $consumes = $this->getSwagger()->getConsumes(); |
|
41 | - } |
|
42 | - |
|
43 | - $valid_consumes = ((int)in_array('multipart/form-data', $consumes)) + ((int)in_array('application/x-www-form-urlencoded', $consumes)); |
|
44 | - if (empty($consumes) || $valid_consumes !== count($consumes)) { |
|
45 | - throw new Exception("File type '{$definition}' without valid consume"); |
|
46 | - } |
|
47 | - } |
|
48 | - |
|
49 | - public function toArray(): array |
|
50 | - { |
|
51 | - return self::arrayFilterNull(array_merge(array( |
|
52 | - 'type' => 'file', |
|
53 | - ), parent::toArray())); |
|
54 | - } |
|
55 | - |
|
56 | - public function __toString() |
|
57 | - { |
|
58 | - return __CLASS__; |
|
59 | - } |
|
20 | + /** |
|
21 | + * @throws Exception |
|
22 | + */ |
|
23 | + protected function parseDefinition($definition) |
|
24 | + { |
|
25 | + $type = strtolower($definition); |
|
26 | + |
|
27 | + if ($type !== 'file') { |
|
28 | + throw new Exception("Not a file: '{$definition}'"); |
|
29 | + } |
|
30 | + |
|
31 | + $parent = $this->getParent(); |
|
32 | + if (!($parent instanceof Parameter) || !$parent->isForm()) { |
|
33 | + throw new Exception("File type '{$definition}' only allowed on form parameter"); |
|
34 | + } |
|
35 | + |
|
36 | + /** @var Operation $parentOperation */ |
|
37 | + $parentOperation = $this->getParentClass(Operation::class); |
|
38 | + $consumes = $parentOperation->getConsumes(); |
|
39 | + if (empty($consumes)) { |
|
40 | + $consumes = $this->getSwagger()->getConsumes(); |
|
41 | + } |
|
42 | + |
|
43 | + $valid_consumes = ((int)in_array('multipart/form-data', $consumes)) + ((int)in_array('application/x-www-form-urlencoded', $consumes)); |
|
44 | + if (empty($consumes) || $valid_consumes !== count($consumes)) { |
|
45 | + throw new Exception("File type '{$definition}' without valid consume"); |
|
46 | + } |
|
47 | + } |
|
48 | + |
|
49 | + public function toArray(): array |
|
50 | + { |
|
51 | + return self::arrayFilterNull(array_merge(array( |
|
52 | + 'type' => 'file', |
|
53 | + ), parent::toArray())); |
|
54 | + } |
|
55 | + |
|
56 | + public function __toString() |
|
57 | + { |
|
58 | + return __CLASS__; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -15,15 +15,15 @@ |
||
15 | 15 | class StringUuidType extends AbstractRegexType |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Construct and set up the regular expression for this type |
|
20 | - * |
|
21 | - * @param AbstractObject $parent |
|
22 | - * @param string $definition |
|
23 | - */ |
|
24 | - public function __construct(AbstractObject $parent, $definition) |
|
25 | - { |
|
26 | - parent::__construct($parent, $definition, 'uuid', '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}'); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Construct and set up the regular expression for this type |
|
20 | + * |
|
21 | + * @param AbstractObject $parent |
|
22 | + * @param string $definition |
|
23 | + */ |
|
24 | + public function __construct(AbstractObject $parent, $definition) |
|
25 | + { |
|
26 | + parent::__construct($parent, $definition, 'uuid', '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}'); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |