1: <?php
2: /**
3: * Order
4: *
5: * PHP version 7.4
6: *
7: * @category Class
8: * @package Ally\PetStore
9: * @author OpenAPI Generator team
10: * @link https://openapi-generator.tech
11: */
12:
13: /**
14: * OpenAPI Petstore
15: *
16: * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
17: *
18: * The version of the OpenAPI document: 1.0.0
19: * Generated by: https://openapi-generator.tech
20: * OpenAPI Generator version: 6.1.0-SNAPSHOT
21: */
22:
23: /**
24: * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
25: * https://openapi-generator.tech
26: * Do not edit the class manually.
27: */
28:
29: namespace Ally\PetStore\Schema;
30:
31: use \ArrayAccess;
32: use \Ally\PetStore\ObjectSerializer;
33:
34: /**
35: * Order Class Doc Comment
36: *
37: * @category Class
38: * @description An order for a pets from the pet store
39: * @package Ally\PetStore
40: * @author OpenAPI Generator team
41: * @link https://openapi-generator.tech
42: * @implements \ArrayAccess<string, mixed>
43: */
44: class Order implements ModelInterface, ArrayAccess, \JsonSerializable
45: {
46: public const DISCRIMINATOR = null;
47:
48: /**
49: * The original name of the model.
50: *
51: * @var string
52: */
53: protected static $openAPIModelName = 'Order';
54:
55: /**
56: * Array of property to type mappings. Used for (de)serialization
57: *
58: * @var string[]
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: * Array of property to format mappings. Used for (de)serialization
71: *
72: * @var string[]
73: * @phpstan-var array<string, string|null>
74: * @psalm-var array<string, string|null>
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: * Array of nullable properties. Used for (de)serialization
87: *
88: * @var boolean[]
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: * If a nullable field gets set to null, insert it here
101: *
102: * @var boolean[]
103: */
104: protected array $openAPINullablesSetToNull = [];
105:
106: /**
107: * Array of property to type mappings. Used for (de)serialization
108: *
109: * @return array
110: */
111: public static function openAPITypes()
112: {
113: return self::$openAPITypes;
114: }
115:
116: /**
117: * Array of property to format mappings. Used for (de)serialization
118: *
119: * @return array
120: */
121: public static function openAPIFormats()
122: {
123: return self::$openAPIFormats;
124: }
125:
126: /**
127: * Array of nullable properties
128: *
129: * @return array
130: */
131: protected static function openAPINullables(): array
132: {
133: return self::$openAPINullables;
134: }
135:
136: /**
137: * Array of nullable field names deliberately set to null
138: *
139: * @return boolean[]
140: */
141: private function getOpenAPINullablesSetToNull(): array
142: {
143: return $this->openAPINullablesSetToNull;
144: }
145:
146: /**
147: * Checks if a property is nullable
148: *
149: * @param string $property
150: * @return bool
151: */
152: public static function isNullable(string $property): bool
153: {
154: return self::openAPINullables()[$property] ?? false;
155: }
156:
157: /**
158: * Checks if a nullable property is set to null.
159: *
160: * @param string $property
161: * @return bool
162: */
163: public function isNullableSetToNull(string $property): bool
164: {
165: return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
166: }
167:
168: /**
169: * Array of attributes where the key is the local name,
170: * and the value is the original name
171: *
172: * @var string[]
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: * Array of attributes to setter functions (for deserialization of responses)
185: *
186: * @var string[]
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: * Array of attributes to getter functions (for serialization of requests)
199: *
200: * @var string[]
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: * Array of attributes where the key is the local name,
213: * and the value is the original name
214: *
215: * @return array
216: */
217: public static function attributeMap()
218: {
219: return self::$attributeMap;
220: }
221:
222: /**
223: * Array of attributes to setter functions (for deserialization of responses)
224: *
225: * @return array
226: */
227: public static function setters()
228: {
229: return self::$setters;
230: }
231:
232: /**
233: * Array of attributes to getter functions (for serialization of requests)
234: *
235: * @return array
236: */
237: public static function getters()
238: {
239: return self::$getters;
240: }
241:
242: /**
243: * The original name of the model.
244: *
245: * @return string
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: * Gets allowable values of the enum
258: *
259: * @return string[]
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: * Associative array for storing property values
272: *
273: * @var mixed[]
274: */
275: protected $container = [];
276:
277: /**
278: * Constructor
279: *
280: * @param mixed[] $data Associated array of property values
281: * initializing the model
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: * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
295: * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
296: * $this->openAPINullablesSetToNull array
297: *
298: * @param string $variableName
299: * @param array $fields
300: * @param mixed $defaultValue
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: * Show all the invalid properties with reasons.
313: *
314: * @return array invalid properties with reasons
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: * Validate all the properties in the model
334: * return true if all passed
335: *
336: * @return bool True if all properties are valid
337: */
338: public function valid()
339: {
340: return count($this->listInvalidProperties()) === 0;
341: }
342:
343:
344: /**
345: * Gets id
346: *
347: * @return int|null
348: */
349: public function getId()
350: {
351: return $this->container['id'];
352: }
353:
354: /**
355: * Sets id
356: *
357: * @param int|null $id id
358: *
359: * @return self
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: * Gets pet_id
375: *
376: * @return int|null
377: */
378: public function getPetId()
379: {
380: return $this->container['pet_id'];
381: }
382:
383: /**
384: * Sets pet_id
385: *
386: * @param int|null $pet_id pet_id
387: *
388: * @return self
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: * Gets quantity
404: *
405: * @return int|null
406: */
407: public function getQuantity()
408: {
409: return $this->container['quantity'];
410: }
411:
412: /**
413: * Sets quantity
414: *
415: * @param int|null $quantity quantity
416: *
417: * @return self
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: * Gets ship_date
433: *
434: * @return \DateTime|null
435: */
436: public function getShipDate()
437: {
438: return $this->container['ship_date'];
439: }
440:
441: /**
442: * Sets ship_date
443: *
444: * @param \DateTime|null $ship_date ship_date
445: *
446: * @return self
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: * Gets status
462: *
463: * @return string|null
464: */
465: public function getStatus()
466: {
467: return $this->container['status'];
468: }
469:
470: /**
471: * Sets status
472: *
473: * @param string|null $status Order Status
474: *
475: * @return self
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: * Gets complete
501: *
502: * @return bool|null
503: */
504: public function getComplete()
505: {
506: return $this->container['complete'];
507: }
508:
509: /**
510: * Sets complete
511: *
512: * @param bool|null $complete complete
513: *
514: * @return self
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: * Returns true if offset exists. False otherwise.
529: *
530: * @param integer $offset Offset
531: *
532: * @return boolean
533: */
534: public function offsetExists($offset): bool
535: {
536: return isset($this->container[$offset]);
537: }
538:
539: /**
540: * Gets offset.
541: *
542: * @param integer $offset Offset
543: *
544: * @return mixed|null
545: */
546: #[\ReturnTypeWillChange]
547: public function offsetGet($offset)
548: {
549: return $this->container[$offset] ?? null;
550: }
551:
552: /**
553: * Sets value based on offset.
554: *
555: * @param int|null $offset Offset
556: * @param mixed $value Value to be set
557: *
558: * @return void
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: * Unsets offset.
571: *
572: * @param integer $offset Offset
573: *
574: * @return void
575: */
576: public function offsetUnset($offset): void
577: {
578: unset($this->container[$offset]);
579: }
580:
581: /**
582: * Serializes the object to a value that can be serialized natively by json_encode().
583: * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
584: *
585: * @return mixed Returns data which can be serialized by json_encode(), which is a value
586: * of any type other than a resource.
587: */
588: #[\ReturnTypeWillChange]
589: public function jsonSerialize()
590: {
591: return ObjectSerializer::sanitizeForSerialization($this);
592: }
593:
594: /**
595: * Gets the string presentation of the object
596: *
597: * @return string
598: */
599: public function __toString()
600: {
601: return json_encode(
602: ObjectSerializer::sanitizeForSerialization($this),
603: JSON_PRETTY_PRINT
604: );
605: }
606:
607: /**
608: * Gets a header-safe presentation of the object
609: *
610: * @return string
611: */
612: public function toHeaderValue()
613: {
614: return json_encode(ObjectSerializer::sanitizeForSerialization($this));
615: }
616: }
617:
618:
619: