1: <?php
2: /**
3: * Pet
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: * Pet Class Doc Comment
36: *
37: * @category Class
38: * @description A pet for sale in 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 Pet 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 = 'Pet';
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: 'category' => '\Ally\PetStore\Schema\Category',
63: 'name' => 'string',
64: 'photo_urls' => 'string[]',
65: 'tags' => '\Ally\PetStore\Schema\Tag[]',
66: 'status' => 'string'
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: 'category' => null,
79: 'name' => null,
80: 'photo_urls' => null,
81: 'tags' => null,
82: 'status' => 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: 'category' => false,
93: 'name' => false,
94: 'photo_urls' => false,
95: 'tags' => false,
96: 'status' => 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: 'category' => 'category',
177: 'name' => 'name',
178: 'photo_urls' => 'photoUrls',
179: 'tags' => 'tags',
180: 'status' => 'status'
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: 'category' => 'setCategory',
191: 'name' => 'setName',
192: 'photo_urls' => 'setPhotoUrls',
193: 'tags' => 'setTags',
194: 'status' => 'setStatus'
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: 'category' => 'getCategory',
205: 'name' => 'getName',
206: 'photo_urls' => 'getPhotoUrls',
207: 'tags' => 'getTags',
208: 'status' => 'getStatus'
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_AVAILABLE = 'available';
253: public const STATUS_PENDING = 'pending';
254: public const STATUS_SOLD = 'sold';
255:
256: /**
257: * Gets allowable values of the enum
258: *
259: * @return string[]
260: */
261: public function getStatusAllowableValues()
262: {
263: return [
264: self::STATUS_AVAILABLE,
265: self::STATUS_PENDING,
266: self::STATUS_SOLD,
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('category', $data ?? [], null);
287: $this->setIfExists('name', $data ?? [], null);
288: $this->setIfExists('photo_urls', $data ?? [], null);
289: $this->setIfExists('tags', $data ?? [], null);
290: $this->setIfExists('status', $data ?? [], null);
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: if ($this->container['name'] === null) {
321: $invalidProperties[] = "'name' can't be null";
322: }
323: if ($this->container['photo_urls'] === null) {
324: $invalidProperties[] = "'photo_urls' can't be null";
325: }
326: $allowedValues = $this->getStatusAllowableValues();
327: if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
328: $invalidProperties[] = sprintf(
329: "invalid value '%s' for 'status', must be one of '%s'",
330: $this->container['status'],
331: implode("', '", $allowedValues)
332: );
333: }
334:
335: return $invalidProperties;
336: }
337:
338: /**
339: * Validate all the properties in the model
340: * return true if all passed
341: *
342: * @return bool True if all properties are valid
343: */
344: public function valid()
345: {
346: return count($this->listInvalidProperties()) === 0;
347: }
348:
349:
350: /**
351: * Gets id
352: *
353: * @return int|null
354: */
355: public function getId()
356: {
357: return $this->container['id'];
358: }
359:
360: /**
361: * Sets id
362: *
363: * @param int|null $id id
364: *
365: * @return self
366: */
367: public function setId($id)
368: {
369:
370: if (is_null($id)) {
371: throw new \InvalidArgumentException('non-nullable id cannot be null');
372: }
373:
374: $this->container['id'] = $id;
375:
376: return $this;
377: }
378:
379: /**
380: * Gets category
381: *
382: * @return \Ally\PetStore\Schema\Category|null
383: */
384: public function getCategory()
385: {
386: return $this->container['category'];
387: }
388:
389: /**
390: * Sets category
391: *
392: * @param \Ally\PetStore\Schema\Category|null $category category
393: *
394: * @return self
395: */
396: public function setCategory($category)
397: {
398:
399: if (is_null($category)) {
400: throw new \InvalidArgumentException('non-nullable category cannot be null');
401: }
402:
403: $this->container['category'] = $category;
404:
405: return $this;
406: }
407:
408: /**
409: * Gets name
410: *
411: * @return string
412: */
413: public function getName()
414: {
415: return $this->container['name'];
416: }
417:
418: /**
419: * Sets name
420: *
421: * @param string $name name
422: *
423: * @return self
424: */
425: public function setName($name)
426: {
427:
428: if (is_null($name)) {
429: throw new \InvalidArgumentException('non-nullable name cannot be null');
430: }
431:
432: $this->container['name'] = $name;
433:
434: return $this;
435: }
436:
437: /**
438: * Gets photo_urls
439: *
440: * @return string[]
441: */
442: public function getPhotoUrls()
443: {
444: return $this->container['photo_urls'];
445: }
446:
447: /**
448: * Sets photo_urls
449: *
450: * @param string[] $photo_urls photo_urls
451: *
452: * @return self
453: */
454: public function setPhotoUrls($photo_urls)
455: {
456:
457: if (is_null($photo_urls)) {
458: throw new \InvalidArgumentException('non-nullable photo_urls cannot be null');
459: }
460:
461: $this->container['photo_urls'] = $photo_urls;
462:
463: return $this;
464: }
465:
466: /**
467: * Gets tags
468: *
469: * @return \Ally\PetStore\Schema\Tag[]|null
470: */
471: public function getTags()
472: {
473: return $this->container['tags'];
474: }
475:
476: /**
477: * Sets tags
478: *
479: * @param \Ally\PetStore\Schema\Tag[]|null $tags tags
480: *
481: * @return self
482: */
483: public function setTags($tags)
484: {
485:
486: if (is_null($tags)) {
487: throw new \InvalidArgumentException('non-nullable tags cannot be null');
488: }
489:
490: $this->container['tags'] = $tags;
491:
492: return $this;
493: }
494:
495: /**
496: * Gets status
497: *
498: * @return string|null
499: * @deprecated
500: */
501: public function getStatus()
502: {
503: return $this->container['status'];
504: }
505:
506: /**
507: * Sets status
508: *
509: * @param string|null $status pet status in the store
510: *
511: * @return self
512: * @deprecated
513: */
514: public function setStatus($status)
515: {
516: $allowedValues = $this->getStatusAllowableValues();
517: if (!is_null($status) && !in_array($status, $allowedValues, true)) {
518: throw new \InvalidArgumentException(
519: sprintf(
520: "Invalid value '%s' for 'status', must be one of '%s'",
521: $status,
522: implode("', '", $allowedValues)
523: )
524: );
525: }
526:
527: if (is_null($status)) {
528: throw new \InvalidArgumentException('non-nullable status cannot be null');
529: }
530:
531: $this->container['status'] = $status;
532:
533: return $this;
534: }
535: /**
536: * Returns true if offset exists. False otherwise.
537: *
538: * @param integer $offset Offset
539: *
540: * @return boolean
541: */
542: public function offsetExists($offset): bool
543: {
544: return isset($this->container[$offset]);
545: }
546:
547: /**
548: * Gets offset.
549: *
550: * @param integer $offset Offset
551: *
552: * @return mixed|null
553: */
554: #[\ReturnTypeWillChange]
555: public function offsetGet($offset)
556: {
557: return $this->container[$offset] ?? null;
558: }
559:
560: /**
561: * Sets value based on offset.
562: *
563: * @param int|null $offset Offset
564: * @param mixed $value Value to be set
565: *
566: * @return void
567: */
568: public function offsetSet($offset, $value): void
569: {
570: if (is_null($offset)) {
571: $this->container[] = $value;
572: } else {
573: $this->container[$offset] = $value;
574: }
575: }
576:
577: /**
578: * Unsets offset.
579: *
580: * @param integer $offset Offset
581: *
582: * @return void
583: */
584: public function offsetUnset($offset): void
585: {
586: unset($this->container[$offset]);
587: }
588:
589: /**
590: * Serializes the object to a value that can be serialized natively by json_encode().
591: * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
592: *
593: * @return mixed Returns data which can be serialized by json_encode(), which is a value
594: * of any type other than a resource.
595: */
596: #[\ReturnTypeWillChange]
597: public function jsonSerialize()
598: {
599: return ObjectSerializer::sanitizeForSerialization($this);
600: }
601:
602: /**
603: * Gets the string presentation of the object
604: *
605: * @return string
606: */
607: public function __toString()
608: {
609: return json_encode(
610: ObjectSerializer::sanitizeForSerialization($this),
611: JSON_PRETTY_PRINT
612: );
613: }
614:
615: /**
616: * Gets a header-safe presentation of the object
617: *
618: * @return string
619: */
620: public function toHeaderValue()
621: {
622: return json_encode(ObjectSerializer::sanitizeForSerialization($this));
623: }
624: }
625:
626:
627: