1: <?php
2: /**
3: * User
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: * User Class Doc Comment
36: *
37: * @category Class
38: * @description A User who is purchasing 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 User 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 = 'User';
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: 'username' => 'string',
63: 'first_name' => 'string',
64: 'last_name' => 'string',
65: 'email' => 'string',
66: 'password' => 'string',
67: 'phone' => 'string',
68: 'user_status' => 'int'
69: ];
70:
71: /**
72: * Array of property to format mappings. Used for (de)serialization
73: *
74: * @var string[]
75: * @phpstan-var array<string, string|null>
76: * @psalm-var array<string, string|null>
77: */
78: protected static $openAPIFormats = [
79: 'id' => 'int64',
80: 'username' => null,
81: 'first_name' => null,
82: 'last_name' => null,
83: 'email' => null,
84: 'password' => null,
85: 'phone' => null,
86: 'user_status' => 'int32'
87: ];
88:
89: /**
90: * Array of nullable properties. Used for (de)serialization
91: *
92: * @var boolean[]
93: */
94: protected static array $openAPINullables = [
95: 'id' => false,
96: 'username' => false,
97: 'first_name' => false,
98: 'last_name' => false,
99: 'email' => false,
100: 'password' => false,
101: 'phone' => false,
102: 'user_status' => false
103: ];
104:
105: /**
106: * If a nullable field gets set to null, insert it here
107: *
108: * @var boolean[]
109: */
110: protected array $openAPINullablesSetToNull = [];
111:
112: /**
113: * Array of property to type mappings. Used for (de)serialization
114: *
115: * @return array
116: */
117: public static function openAPITypes()
118: {
119: return self::$openAPITypes;
120: }
121:
122: /**
123: * Array of property to format mappings. Used for (de)serialization
124: *
125: * @return array
126: */
127: public static function openAPIFormats()
128: {
129: return self::$openAPIFormats;
130: }
131:
132: /**
133: * Array of nullable properties
134: *
135: * @return array
136: */
137: protected static function openAPINullables(): array
138: {
139: return self::$openAPINullables;
140: }
141:
142: /**
143: * Array of nullable field names deliberately set to null
144: *
145: * @return boolean[]
146: */
147: private function getOpenAPINullablesSetToNull(): array
148: {
149: return $this->openAPINullablesSetToNull;
150: }
151:
152: /**
153: * Checks if a property is nullable
154: *
155: * @param string $property
156: * @return bool
157: */
158: public static function isNullable(string $property): bool
159: {
160: return self::openAPINullables()[$property] ?? false;
161: }
162:
163: /**
164: * Checks if a nullable property is set to null.
165: *
166: * @param string $property
167: * @return bool
168: */
169: public function isNullableSetToNull(string $property): bool
170: {
171: return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
172: }
173:
174: /**
175: * Array of attributes where the key is the local name,
176: * and the value is the original name
177: *
178: * @var string[]
179: */
180: protected static $attributeMap = [
181: 'id' => 'id',
182: 'username' => 'username',
183: 'first_name' => 'firstName',
184: 'last_name' => 'lastName',
185: 'email' => 'email',
186: 'password' => 'password',
187: 'phone' => 'phone',
188: 'user_status' => 'userStatus'
189: ];
190:
191: /**
192: * Array of attributes to setter functions (for deserialization of responses)
193: *
194: * @var string[]
195: */
196: protected static $setters = [
197: 'id' => 'setId',
198: 'username' => 'setUsername',
199: 'first_name' => 'setFirstName',
200: 'last_name' => 'setLastName',
201: 'email' => 'setEmail',
202: 'password' => 'setPassword',
203: 'phone' => 'setPhone',
204: 'user_status' => 'setUserStatus'
205: ];
206:
207: /**
208: * Array of attributes to getter functions (for serialization of requests)
209: *
210: * @var string[]
211: */
212: protected static $getters = [
213: 'id' => 'getId',
214: 'username' => 'getUsername',
215: 'first_name' => 'getFirstName',
216: 'last_name' => 'getLastName',
217: 'email' => 'getEmail',
218: 'password' => 'getPassword',
219: 'phone' => 'getPhone',
220: 'user_status' => 'getUserStatus'
221: ];
222:
223: /**
224: * Array of attributes where the key is the local name,
225: * and the value is the original name
226: *
227: * @return array
228: */
229: public static function attributeMap()
230: {
231: return self::$attributeMap;
232: }
233:
234: /**
235: * Array of attributes to setter functions (for deserialization of responses)
236: *
237: * @return array
238: */
239: public static function setters()
240: {
241: return self::$setters;
242: }
243:
244: /**
245: * Array of attributes to getter functions (for serialization of requests)
246: *
247: * @return array
248: */
249: public static function getters()
250: {
251: return self::$getters;
252: }
253:
254: /**
255: * The original name of the model.
256: *
257: * @return string
258: */
259: public function getModelName()
260: {
261: return self::$openAPIModelName;
262: }
263:
264:
265: /**
266: * Associative array for storing property values
267: *
268: * @var mixed[]
269: */
270: protected $container = [];
271:
272: /**
273: * Constructor
274: *
275: * @param mixed[] $data Associated array of property values
276: * initializing the model
277: */
278: public function __construct(array $data = null)
279: {
280: $this->setIfExists('id', $data ?? [], null);
281: $this->setIfExists('username', $data ?? [], null);
282: $this->setIfExists('first_name', $data ?? [], null);
283: $this->setIfExists('last_name', $data ?? [], null);
284: $this->setIfExists('email', $data ?? [], null);
285: $this->setIfExists('password', $data ?? [], null);
286: $this->setIfExists('phone', $data ?? [], null);
287: $this->setIfExists('user_status', $data ?? [], null);
288: }
289:
290: /**
291: * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
292: * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
293: * $this->openAPINullablesSetToNull array
294: *
295: * @param string $variableName
296: * @param array $fields
297: * @param mixed $defaultValue
298: */
299: private function setIfExists(string $variableName, array $fields, $defaultValue): void
300: {
301: if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
302: $this->openAPINullablesSetToNull[] = $variableName;
303: }
304:
305: $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
306: }
307:
308: /**
309: * Show all the invalid properties with reasons.
310: *
311: * @return array invalid properties with reasons
312: */
313: public function listInvalidProperties()
314: {
315: $invalidProperties = [];
316:
317: return $invalidProperties;
318: }
319:
320: /**
321: * Validate all the properties in the model
322: * return true if all passed
323: *
324: * @return bool True if all properties are valid
325: */
326: public function valid()
327: {
328: return count($this->listInvalidProperties()) === 0;
329: }
330:
331:
332: /**
333: * Gets id
334: *
335: * @return int|null
336: */
337: public function getId()
338: {
339: return $this->container['id'];
340: }
341:
342: /**
343: * Sets id
344: *
345: * @param int|null $id id
346: *
347: * @return self
348: */
349: public function setId($id)
350: {
351:
352: if (is_null($id)) {
353: throw new \InvalidArgumentException('non-nullable id cannot be null');
354: }
355:
356: $this->container['id'] = $id;
357:
358: return $this;
359: }
360:
361: /**
362: * Gets username
363: *
364: * @return string|null
365: */
366: public function getUsername()
367: {
368: return $this->container['username'];
369: }
370:
371: /**
372: * Sets username
373: *
374: * @param string|null $username username
375: *
376: * @return self
377: */
378: public function setUsername($username)
379: {
380:
381: if (is_null($username)) {
382: throw new \InvalidArgumentException('non-nullable username cannot be null');
383: }
384:
385: $this->container['username'] = $username;
386:
387: return $this;
388: }
389:
390: /**
391: * Gets first_name
392: *
393: * @return string|null
394: */
395: public function getFirstName()
396: {
397: return $this->container['first_name'];
398: }
399:
400: /**
401: * Sets first_name
402: *
403: * @param string|null $first_name first_name
404: *
405: * @return self
406: */
407: public function setFirstName($first_name)
408: {
409:
410: if (is_null($first_name)) {
411: throw new \InvalidArgumentException('non-nullable first_name cannot be null');
412: }
413:
414: $this->container['first_name'] = $first_name;
415:
416: return $this;
417: }
418:
419: /**
420: * Gets last_name
421: *
422: * @return string|null
423: */
424: public function getLastName()
425: {
426: return $this->container['last_name'];
427: }
428:
429: /**
430: * Sets last_name
431: *
432: * @param string|null $last_name last_name
433: *
434: * @return self
435: */
436: public function setLastName($last_name)
437: {
438:
439: if (is_null($last_name)) {
440: throw new \InvalidArgumentException('non-nullable last_name cannot be null');
441: }
442:
443: $this->container['last_name'] = $last_name;
444:
445: return $this;
446: }
447:
448: /**
449: * Gets email
450: *
451: * @return string|null
452: */
453: public function getEmail()
454: {
455: return $this->container['email'];
456: }
457:
458: /**
459: * Sets email
460: *
461: * @param string|null $email email
462: *
463: * @return self
464: */
465: public function setEmail($email)
466: {
467:
468: if (is_null($email)) {
469: throw new \InvalidArgumentException('non-nullable email cannot be null');
470: }
471:
472: $this->container['email'] = $email;
473:
474: return $this;
475: }
476:
477: /**
478: * Gets password
479: *
480: * @return string|null
481: */
482: public function getPassword()
483: {
484: return $this->container['password'];
485: }
486:
487: /**
488: * Sets password
489: *
490: * @param string|null $password password
491: *
492: * @return self
493: */
494: public function setPassword($password)
495: {
496:
497: if (is_null($password)) {
498: throw new \InvalidArgumentException('non-nullable password cannot be null');
499: }
500:
501: $this->container['password'] = $password;
502:
503: return $this;
504: }
505:
506: /**
507: * Gets phone
508: *
509: * @return string|null
510: */
511: public function getPhone()
512: {
513: return $this->container['phone'];
514: }
515:
516: /**
517: * Sets phone
518: *
519: * @param string|null $phone phone
520: *
521: * @return self
522: */
523: public function setPhone($phone)
524: {
525:
526: if (is_null($phone)) {
527: throw new \InvalidArgumentException('non-nullable phone cannot be null');
528: }
529:
530: $this->container['phone'] = $phone;
531:
532: return $this;
533: }
534:
535: /**
536: * Gets user_status
537: *
538: * @return int|null
539: */
540: public function getUserStatus()
541: {
542: return $this->container['user_status'];
543: }
544:
545: /**
546: * Sets user_status
547: *
548: * @param int|null $user_status User Status
549: *
550: * @return self
551: */
552: public function setUserStatus($user_status)
553: {
554:
555: if (is_null($user_status)) {
556: throw new \InvalidArgumentException('non-nullable user_status cannot be null');
557: }
558:
559: $this->container['user_status'] = $user_status;
560:
561: return $this;
562: }
563: /**
564: * Returns true if offset exists. False otherwise.
565: *
566: * @param integer $offset Offset
567: *
568: * @return boolean
569: */
570: public function offsetExists($offset): bool
571: {
572: return isset($this->container[$offset]);
573: }
574:
575: /**
576: * Gets offset.
577: *
578: * @param integer $offset Offset
579: *
580: * @return mixed|null
581: */
582: #[\ReturnTypeWillChange]
583: public function offsetGet($offset)
584: {
585: return $this->container[$offset] ?? null;
586: }
587:
588: /**
589: * Sets value based on offset.
590: *
591: * @param int|null $offset Offset
592: * @param mixed $value Value to be set
593: *
594: * @return void
595: */
596: public function offsetSet($offset, $value): void
597: {
598: if (is_null($offset)) {
599: $this->container[] = $value;
600: } else {
601: $this->container[$offset] = $value;
602: }
603: }
604:
605: /**
606: * Unsets offset.
607: *
608: * @param integer $offset Offset
609: *
610: * @return void
611: */
612: public function offsetUnset($offset): void
613: {
614: unset($this->container[$offset]);
615: }
616:
617: /**
618: * Serializes the object to a value that can be serialized natively by json_encode().
619: * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
620: *
621: * @return mixed Returns data which can be serialized by json_encode(), which is a value
622: * of any type other than a resource.
623: */
624: #[\ReturnTypeWillChange]
625: public function jsonSerialize()
626: {
627: return ObjectSerializer::sanitizeForSerialization($this);
628: }
629:
630: /**
631: * Gets the string presentation of the object
632: *
633: * @return string
634: */
635: public function __toString()
636: {
637: return json_encode(
638: ObjectSerializer::sanitizeForSerialization($this),
639: JSON_PRETTY_PRINT
640: );
641: }
642:
643: /**
644: * Gets a header-safe presentation of the object
645: *
646: * @return string
647: */
648: public function toHeaderValue()
649: {
650: return json_encode(ObjectSerializer::sanitizeForSerialization($this));
651: }
652: }
653:
654:
655: