1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | namespace Ally\PetStore\Schema; |
30: | |
31: | use \ArrayAccess; |
32: | use \Ally\PetStore\ObjectSerializer; |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | class ApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable |
45: | { |
46: | public const DISCRIMINATOR = null; |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | protected static $openAPIModelName = 'ApiResponse'; |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | |
60: | protected static $openAPITypes = [ |
61: | 'code' => 'int', |
62: | 'type' => 'string', |
63: | 'message' => 'string' |
64: | ]; |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | |
73: | protected static $openAPIFormats = [ |
74: | 'code' => 'int32', |
75: | 'type' => null, |
76: | 'message' => null |
77: | ]; |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | |
84: | protected static array $openAPINullables = [ |
85: | 'code' => false, |
86: | 'type' => false, |
87: | 'message' => false |
88: | ]; |
89: | |
90: | |
91: | |
92: | |
93: | |
94: | |
95: | protected array $openAPINullablesSetToNull = []; |
96: | |
97: | |
98: | |
99: | |
100: | |
101: | |
102: | public static function openAPITypes() |
103: | { |
104: | return self::$openAPITypes; |
105: | } |
106: | |
107: | |
108: | |
109: | |
110: | |
111: | |
112: | public static function openAPIFormats() |
113: | { |
114: | return self::$openAPIFormats; |
115: | } |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | protected static function openAPINullables(): array |
123: | { |
124: | return self::$openAPINullables; |
125: | } |
126: | |
127: | |
128: | |
129: | |
130: | |
131: | |
132: | private function getOpenAPINullablesSetToNull(): array |
133: | { |
134: | return $this->openAPINullablesSetToNull; |
135: | } |
136: | |
137: | |
138: | |
139: | |
140: | |
141: | |
142: | |
143: | public static function isNullable(string $property): bool |
144: | { |
145: | return self::openAPINullables()[$property] ?? false; |
146: | } |
147: | |
148: | |
149: | |
150: | |
151: | |
152: | |
153: | |
154: | public function isNullableSetToNull(string $property): bool |
155: | { |
156: | return in_array($property, $this->getOpenAPINullablesSetToNull(), true); |
157: | } |
158: | |
159: | |
160: | |
161: | |
162: | |
163: | |
164: | |
165: | protected static $attributeMap = [ |
166: | 'code' => 'code', |
167: | 'type' => 'type', |
168: | 'message' => 'message' |
169: | ]; |
170: | |
171: | |
172: | |
173: | |
174: | |
175: | |
176: | protected static $setters = [ |
177: | 'code' => 'setCode', |
178: | 'type' => 'setType', |
179: | 'message' => 'setMessage' |
180: | ]; |
181: | |
182: | |
183: | |
184: | |
185: | |
186: | |
187: | protected static $getters = [ |
188: | 'code' => 'getCode', |
189: | 'type' => 'getType', |
190: | 'message' => 'getMessage' |
191: | ]; |
192: | |
193: | |
194: | |
195: | |
196: | |
197: | |
198: | |
199: | public static function attributeMap() |
200: | { |
201: | return self::$attributeMap; |
202: | } |
203: | |
204: | |
205: | |
206: | |
207: | |
208: | |
209: | public static function setters() |
210: | { |
211: | return self::$setters; |
212: | } |
213: | |
214: | |
215: | |
216: | |
217: | |
218: | |
219: | public static function getters() |
220: | { |
221: | return self::$getters; |
222: | } |
223: | |
224: | |
225: | |
226: | |
227: | |
228: | |
229: | public function getModelName() |
230: | { |
231: | return self::$openAPIModelName; |
232: | } |
233: | |
234: | |
235: | |
236: | |
237: | |
238: | |
239: | |
240: | protected $container = []; |
241: | |
242: | |
243: | |
244: | |
245: | |
246: | |
247: | |
248: | public function __construct(array $data = null) |
249: | { |
250: | $this->setIfExists('code', $data ?? [], null); |
251: | $this->setIfExists('type', $data ?? [], null); |
252: | $this->setIfExists('message', $data ?? [], null); |
253: | } |
254: | |
255: | |
256: | |
257: | |
258: | |
259: | |
260: | |
261: | |
262: | |
263: | |
264: | private function setIfExists(string $variableName, array $fields, $defaultValue): void |
265: | { |
266: | if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { |
267: | $this->openAPINullablesSetToNull[] = $variableName; |
268: | } |
269: | |
270: | $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; |
271: | } |
272: | |
273: | |
274: | |
275: | |
276: | |
277: | |
278: | public function listInvalidProperties() |
279: | { |
280: | $invalidProperties = []; |
281: | |
282: | return $invalidProperties; |
283: | } |
284: | |
285: | |
286: | |
287: | |
288: | |
289: | |
290: | |
291: | public function valid() |
292: | { |
293: | return count($this->listInvalidProperties()) === 0; |
294: | } |
295: | |
296: | |
297: | |
298: | |
299: | |
300: | |
301: | |
302: | public function getCode() |
303: | { |
304: | return $this->container['code']; |
305: | } |
306: | |
307: | |
308: | |
309: | |
310: | |
311: | |
312: | |
313: | |
314: | public function setCode($code) |
315: | { |
316: | |
317: | if (is_null($code)) { |
318: | throw new \InvalidArgumentException('non-nullable code cannot be null'); |
319: | } |
320: | |
321: | $this->container['code'] = $code; |
322: | |
323: | return $this; |
324: | } |
325: | |
326: | |
327: | |
328: | |
329: | |
330: | |
331: | public function getType() |
332: | { |
333: | return $this->container['type']; |
334: | } |
335: | |
336: | |
337: | |
338: | |
339: | |
340: | |
341: | |
342: | |
343: | public function setType($type) |
344: | { |
345: | |
346: | if (is_null($type)) { |
347: | throw new \InvalidArgumentException('non-nullable type cannot be null'); |
348: | } |
349: | |
350: | $this->container['type'] = $type; |
351: | |
352: | return $this; |
353: | } |
354: | |
355: | |
356: | |
357: | |
358: | |
359: | |
360: | public function getMessage() |
361: | { |
362: | return $this->container['message']; |
363: | } |
364: | |
365: | |
366: | |
367: | |
368: | |
369: | |
370: | |
371: | |
372: | public function setMessage($message) |
373: | { |
374: | |
375: | if (is_null($message)) { |
376: | throw new \InvalidArgumentException('non-nullable message cannot be null'); |
377: | } |
378: | |
379: | $this->container['message'] = $message; |
380: | |
381: | return $this; |
382: | } |
383: | |
384: | |
385: | |
386: | |
387: | |
388: | |
389: | |
390: | public function offsetExists($offset): bool |
391: | { |
392: | return isset($this->container[$offset]); |
393: | } |
394: | |
395: | |
396: | |
397: | |
398: | |
399: | |
400: | |
401: | |
402: | #[\ReturnTypeWillChange] |
403: | public function offsetGet($offset) |
404: | { |
405: | return $this->container[$offset] ?? null; |
406: | } |
407: | |
408: | |
409: | |
410: | |
411: | |
412: | |
413: | |
414: | |
415: | |
416: | public function offsetSet($offset, $value): void |
417: | { |
418: | if (is_null($offset)) { |
419: | $this->container[] = $value; |
420: | } else { |
421: | $this->container[$offset] = $value; |
422: | } |
423: | } |
424: | |
425: | |
426: | |
427: | |
428: | |
429: | |
430: | |
431: | |
432: | public function offsetUnset($offset): void |
433: | { |
434: | unset($this->container[$offset]); |
435: | } |
436: | |
437: | |
438: | |
439: | |
440: | |
441: | |
442: | |
443: | |
444: | #[\ReturnTypeWillChange] |
445: | public function jsonSerialize() |
446: | { |
447: | return ObjectSerializer::sanitizeForSerialization($this); |
448: | } |
449: | |
450: | |
451: | |
452: | |
453: | |
454: | |
455: | public function __toString() |
456: | { |
457: | return json_encode( |
458: | ObjectSerializer::sanitizeForSerialization($this), |
459: | JSON_PRETTY_PRINT |
460: | ); |
461: | } |
462: | |
463: | |
464: | |
465: | |
466: | |
467: | |
468: | public function toHeaderValue() |
469: | { |
470: | return json_encode(ObjectSerializer::sanitizeForSerialization($this)); |
471: | } |
472: | } |
473: | |
474: | |
475: | |