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 Order implements ModelInterface, ArrayAccess, \JsonSerializable |
45: | { |
46: | public const DISCRIMINATOR = null; |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | protected static $openAPIModelName = 'Order'; |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | |
60: | protected static $openAPITypes = [ |
61: | 'id' => 'int', |
62: | 'pet_id' => 'int', |
63: | 'quantity' => 'int', |
64: | 'ship_date' => '\DateTime', |
65: | 'status' => 'string', |
66: | 'complete' => 'bool' |
67: | ]; |
68: | |
69: | |
70: | |
71: | |
72: | |
73: | |
74: | |
75: | |
76: | protected static $openAPIFormats = [ |
77: | 'id' => 'int64', |
78: | 'pet_id' => 'int64', |
79: | 'quantity' => 'int32', |
80: | 'ship_date' => 'date-time', |
81: | 'status' => null, |
82: | 'complete' => null |
83: | ]; |
84: | |
85: | |
86: | |
87: | |
88: | |
89: | |
90: | protected static array $openAPINullables = [ |
91: | 'id' => false, |
92: | 'pet_id' => false, |
93: | 'quantity' => false, |
94: | 'ship_date' => false, |
95: | 'status' => false, |
96: | 'complete' => false |
97: | ]; |
98: | |
99: | |
100: | |
101: | |
102: | |
103: | |
104: | protected array $openAPINullablesSetToNull = []; |
105: | |
106: | |
107: | |
108: | |
109: | |
110: | |
111: | public static function openAPITypes() |
112: | { |
113: | return self::$openAPITypes; |
114: | } |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | public static function openAPIFormats() |
122: | { |
123: | return self::$openAPIFormats; |
124: | } |
125: | |
126: | |
127: | |
128: | |
129: | |
130: | |
131: | protected static function openAPINullables(): array |
132: | { |
133: | return self::$openAPINullables; |
134: | } |
135: | |
136: | |
137: | |
138: | |
139: | |
140: | |
141: | private function getOpenAPINullablesSetToNull(): array |
142: | { |
143: | return $this->openAPINullablesSetToNull; |
144: | } |
145: | |
146: | |
147: | |
148: | |
149: | |
150: | |
151: | |
152: | public static function isNullable(string $property): bool |
153: | { |
154: | return self::openAPINullables()[$property] ?? false; |
155: | } |
156: | |
157: | |
158: | |
159: | |
160: | |
161: | |
162: | |
163: | public function isNullableSetToNull(string $property): bool |
164: | { |
165: | return in_array($property, $this->getOpenAPINullablesSetToNull(), true); |
166: | } |
167: | |
168: | |
169: | |
170: | |
171: | |
172: | |
173: | |
174: | protected static $attributeMap = [ |
175: | 'id' => 'id', |
176: | 'pet_id' => 'petId', |
177: | 'quantity' => 'quantity', |
178: | 'ship_date' => 'shipDate', |
179: | 'status' => 'status', |
180: | 'complete' => 'complete' |
181: | ]; |
182: | |
183: | |
184: | |
185: | |
186: | |
187: | |
188: | protected static $setters = [ |
189: | 'id' => 'setId', |
190: | 'pet_id' => 'setPetId', |
191: | 'quantity' => 'setQuantity', |
192: | 'ship_date' => 'setShipDate', |
193: | 'status' => 'setStatus', |
194: | 'complete' => 'setComplete' |
195: | ]; |
196: | |
197: | |
198: | |
199: | |
200: | |
201: | |
202: | protected static $getters = [ |
203: | 'id' => 'getId', |
204: | 'pet_id' => 'getPetId', |
205: | 'quantity' => 'getQuantity', |
206: | 'ship_date' => 'getShipDate', |
207: | 'status' => 'getStatus', |
208: | 'complete' => 'getComplete' |
209: | ]; |
210: | |
211: | |
212: | |
213: | |
214: | |
215: | |
216: | |
217: | public static function attributeMap() |
218: | { |
219: | return self::$attributeMap; |
220: | } |
221: | |
222: | |
223: | |
224: | |
225: | |
226: | |
227: | public static function setters() |
228: | { |
229: | return self::$setters; |
230: | } |
231: | |
232: | |
233: | |
234: | |
235: | |
236: | |
237: | public static function getters() |
238: | { |
239: | return self::$getters; |
240: | } |
241: | |
242: | |
243: | |
244: | |
245: | |
246: | |
247: | public function getModelName() |
248: | { |
249: | return self::$openAPIModelName; |
250: | } |
251: | |
252: | public const STATUS_PLACED = 'placed'; |
253: | public const STATUS_APPROVED = 'approved'; |
254: | public const STATUS_DELIVERED = 'delivered'; |
255: | |
256: | |
257: | |
258: | |
259: | |
260: | |
261: | public function getStatusAllowableValues() |
262: | { |
263: | return [ |
264: | self::STATUS_PLACED, |
265: | self::STATUS_APPROVED, |
266: | self::STATUS_DELIVERED, |
267: | ]; |
268: | } |
269: | |
270: | |
271: | |
272: | |
273: | |
274: | |
275: | protected $container = []; |
276: | |
277: | |
278: | |
279: | |
280: | |
281: | |
282: | |
283: | public function __construct(array $data = null) |
284: | { |
285: | $this->setIfExists('id', $data ?? [], null); |
286: | $this->setIfExists('pet_id', $data ?? [], null); |
287: | $this->setIfExists('quantity', $data ?? [], null); |
288: | $this->setIfExists('ship_date', $data ?? [], null); |
289: | $this->setIfExists('status', $data ?? [], null); |
290: | $this->setIfExists('complete', $data ?? [], false); |
291: | } |
292: | |
293: | |
294: | |
295: | |
296: | |
297: | |
298: | |
299: | |
300: | |
301: | |
302: | private function setIfExists(string $variableName, array $fields, $defaultValue): void |
303: | { |
304: | if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { |
305: | $this->openAPINullablesSetToNull[] = $variableName; |
306: | } |
307: | |
308: | $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; |
309: | } |
310: | |
311: | |
312: | |
313: | |
314: | |
315: | |
316: | public function listInvalidProperties() |
317: | { |
318: | $invalidProperties = []; |
319: | |
320: | $allowedValues = $this->getStatusAllowableValues(); |
321: | if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { |
322: | $invalidProperties[] = sprintf( |
323: | "invalid value '%s' for 'status', must be one of '%s'", |
324: | $this->container['status'], |
325: | implode("', '", $allowedValues) |
326: | ); |
327: | } |
328: | |
329: | return $invalidProperties; |
330: | } |
331: | |
332: | |
333: | |
334: | |
335: | |
336: | |
337: | |
338: | public function valid() |
339: | { |
340: | return count($this->listInvalidProperties()) === 0; |
341: | } |
342: | |
343: | |
344: | |
345: | |
346: | |
347: | |
348: | |
349: | public function getId() |
350: | { |
351: | return $this->container['id']; |
352: | } |
353: | |
354: | |
355: | |
356: | |
357: | |
358: | |
359: | |
360: | |
361: | public function setId($id) |
362: | { |
363: | |
364: | if (is_null($id)) { |
365: | throw new \InvalidArgumentException('non-nullable id cannot be null'); |
366: | } |
367: | |
368: | $this->container['id'] = $id; |
369: | |
370: | return $this; |
371: | } |
372: | |
373: | |
374: | |
375: | |
376: | |
377: | |
378: | public function getPetId() |
379: | { |
380: | return $this->container['pet_id']; |
381: | } |
382: | |
383: | |
384: | |
385: | |
386: | |
387: | |
388: | |
389: | |
390: | public function setPetId($pet_id) |
391: | { |
392: | |
393: | if (is_null($pet_id)) { |
394: | throw new \InvalidArgumentException('non-nullable pet_id cannot be null'); |
395: | } |
396: | |
397: | $this->container['pet_id'] = $pet_id; |
398: | |
399: | return $this; |
400: | } |
401: | |
402: | |
403: | |
404: | |
405: | |
406: | |
407: | public function getQuantity() |
408: | { |
409: | return $this->container['quantity']; |
410: | } |
411: | |
412: | |
413: | |
414: | |
415: | |
416: | |
417: | |
418: | |
419: | public function setQuantity($quantity) |
420: | { |
421: | |
422: | if (is_null($quantity)) { |
423: | throw new \InvalidArgumentException('non-nullable quantity cannot be null'); |
424: | } |
425: | |
426: | $this->container['quantity'] = $quantity; |
427: | |
428: | return $this; |
429: | } |
430: | |
431: | |
432: | |
433: | |
434: | |
435: | |
436: | public function getShipDate() |
437: | { |
438: | return $this->container['ship_date']; |
439: | } |
440: | |
441: | |
442: | |
443: | |
444: | |
445: | |
446: | |
447: | |
448: | public function setShipDate($ship_date) |
449: | { |
450: | |
451: | if (is_null($ship_date)) { |
452: | throw new \InvalidArgumentException('non-nullable ship_date cannot be null'); |
453: | } |
454: | |
455: | $this->container['ship_date'] = $ship_date; |
456: | |
457: | return $this; |
458: | } |
459: | |
460: | |
461: | |
462: | |
463: | |
464: | |
465: | public function getStatus() |
466: | { |
467: | return $this->container['status']; |
468: | } |
469: | |
470: | |
471: | |
472: | |
473: | |
474: | |
475: | |
476: | |
477: | public function setStatus($status) |
478: | { |
479: | $allowedValues = $this->getStatusAllowableValues(); |
480: | if (!is_null($status) && !in_array($status, $allowedValues, true)) { |
481: | throw new \InvalidArgumentException( |
482: | sprintf( |
483: | "Invalid value '%s' for 'status', must be one of '%s'", |
484: | $status, |
485: | implode("', '", $allowedValues) |
486: | ) |
487: | ); |
488: | } |
489: | |
490: | if (is_null($status)) { |
491: | throw new \InvalidArgumentException('non-nullable status cannot be null'); |
492: | } |
493: | |
494: | $this->container['status'] = $status; |
495: | |
496: | return $this; |
497: | } |
498: | |
499: | |
500: | |
501: | |
502: | |
503: | |
504: | public function getComplete() |
505: | { |
506: | return $this->container['complete']; |
507: | } |
508: | |
509: | |
510: | |
511: | |
512: | |
513: | |
514: | |
515: | |
516: | public function setComplete($complete) |
517: | { |
518: | |
519: | if (is_null($complete)) { |
520: | throw new \InvalidArgumentException('non-nullable complete cannot be null'); |
521: | } |
522: | |
523: | $this->container['complete'] = $complete; |
524: | |
525: | return $this; |
526: | } |
527: | |
528: | |
529: | |
530: | |
531: | |
532: | |
533: | |
534: | public function offsetExists($offset): bool |
535: | { |
536: | return isset($this->container[$offset]); |
537: | } |
538: | |
539: | |
540: | |
541: | |
542: | |
543: | |
544: | |
545: | |
546: | #[\ReturnTypeWillChange] |
547: | public function offsetGet($offset) |
548: | { |
549: | return $this->container[$offset] ?? null; |
550: | } |
551: | |
552: | |
553: | |
554: | |
555: | |
556: | |
557: | |
558: | |
559: | |
560: | public function offsetSet($offset, $value): void |
561: | { |
562: | if (is_null($offset)) { |
563: | $this->container[] = $value; |
564: | } else { |
565: | $this->container[$offset] = $value; |
566: | } |
567: | } |
568: | |
569: | |
570: | |
571: | |
572: | |
573: | |
574: | |
575: | |
576: | public function offsetUnset($offset): void |
577: | { |
578: | unset($this->container[$offset]); |
579: | } |
580: | |
581: | |
582: | |
583: | |
584: | |
585: | |
586: | |
587: | |
588: | #[\ReturnTypeWillChange] |
589: | public function jsonSerialize() |
590: | { |
591: | return ObjectSerializer::sanitizeForSerialization($this); |
592: | } |
593: | |
594: | |
595: | |
596: | |
597: | |
598: | |
599: | public function __toString() |
600: | { |
601: | return json_encode( |
602: | ObjectSerializer::sanitizeForSerialization($this), |
603: | JSON_PRETTY_PRINT |
604: | ); |
605: | } |
606: | |
607: | |
608: | |
609: | |
610: | |
611: | |
612: | public function toHeaderValue() |
613: | { |
614: | return json_encode(ObjectSerializer::sanitizeForSerialization($this)); |
615: | } |
616: | } |
617: | |
618: | |
619: | |