1: <?php
2: /**
3: * ApiResponse
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: * ApiResponse Class Doc Comment
36: *
37: * @category Class
38: * @description Describes the result of uploading an image resource
39: * @package Ally\PetStore
40: * @author OpenAPI Generator team
41: * @link https://openapi-generator.tech
42: * @implements \ArrayAccess<string, mixed>
43: */
44: class ApiResponse 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 = 'ApiResponse';
54:
55: /**
56: * Array of property to type mappings. Used for (de)serialization
57: *
58: * @var string[]
59: */
60: protected static $openAPITypes = [
61: 'code' => 'int',
62: 'type' => 'string',
63: 'message' => 'string'
64: ];
65:
66: /**
67: * Array of property to format mappings. Used for (de)serialization
68: *
69: * @var string[]
70: * @phpstan-var array<string, string|null>
71: * @psalm-var array<string, string|null>
72: */
73: protected static $openAPIFormats = [
74: 'code' => 'int32',
75: 'type' => null,
76: 'message' => null
77: ];
78:
79: /**
80: * Array of nullable properties. Used for (de)serialization
81: *
82: * @var boolean[]
83: */
84: protected static array $openAPINullables = [
85: 'code' => false,
86: 'type' => false,
87: 'message' => false
88: ];
89:
90: /**
91: * If a nullable field gets set to null, insert it here
92: *
93: * @var boolean[]
94: */
95: protected array $openAPINullablesSetToNull = [];
96:
97: /**
98: * Array of property to type mappings. Used for (de)serialization
99: *
100: * @return array
101: */
102: public static function openAPITypes()
103: {
104: return self::$openAPITypes;
105: }
106:
107: /**
108: * Array of property to format mappings. Used for (de)serialization
109: *
110: * @return array
111: */
112: public static function openAPIFormats()
113: {
114: return self::$openAPIFormats;
115: }
116:
117: /**
118: * Array of nullable properties
119: *
120: * @return array
121: */
122: protected static function openAPINullables(): array
123: {
124: return self::$openAPINullables;
125: }
126:
127: /**
128: * Array of nullable field names deliberately set to null
129: *
130: * @return boolean[]
131: */
132: private function getOpenAPINullablesSetToNull(): array
133: {
134: return $this->openAPINullablesSetToNull;
135: }
136:
137: /**
138: * Checks if a property is nullable
139: *
140: * @param string $property
141: * @return bool
142: */
143: public static function isNullable(string $property): bool
144: {
145: return self::openAPINullables()[$property] ?? false;
146: }
147:
148: /**
149: * Checks if a nullable property is set to null.
150: *
151: * @param string $property
152: * @return bool
153: */
154: public function isNullableSetToNull(string $property): bool
155: {
156: return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
157: }
158:
159: /**
160: * Array of attributes where the key is the local name,
161: * and the value is the original name
162: *
163: * @var string[]
164: */
165: protected static $attributeMap = [
166: 'code' => 'code',
167: 'type' => 'type',
168: 'message' => 'message'
169: ];
170:
171: /**
172: * Array of attributes to setter functions (for deserialization of responses)
173: *
174: * @var string[]
175: */
176: protected static $setters = [
177: 'code' => 'setCode',
178: 'type' => 'setType',
179: 'message' => 'setMessage'
180: ];
181:
182: /**
183: * Array of attributes to getter functions (for serialization of requests)
184: *
185: * @var string[]
186: */
187: protected static $getters = [
188: 'code' => 'getCode',
189: 'type' => 'getType',
190: 'message' => 'getMessage'
191: ];
192:
193: /**
194: * Array of attributes where the key is the local name,
195: * and the value is the original name
196: *
197: * @return array
198: */
199: public static function attributeMap()
200: {
201: return self::$attributeMap;
202: }
203:
204: /**
205: * Array of attributes to setter functions (for deserialization of responses)
206: *
207: * @return array
208: */
209: public static function setters()
210: {
211: return self::$setters;
212: }
213:
214: /**
215: * Array of attributes to getter functions (for serialization of requests)
216: *
217: * @return array
218: */
219: public static function getters()
220: {
221: return self::$getters;
222: }
223:
224: /**
225: * The original name of the model.
226: *
227: * @return string
228: */
229: public function getModelName()
230: {
231: return self::$openAPIModelName;
232: }
233:
234:
235: /**
236: * Associative array for storing property values
237: *
238: * @var mixed[]
239: */
240: protected $container = [];
241:
242: /**
243: * Constructor
244: *
245: * @param mixed[] $data Associated array of property values
246: * initializing the model
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: * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
257: * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
258: * $this->openAPINullablesSetToNull array
259: *
260: * @param string $variableName
261: * @param array $fields
262: * @param mixed $defaultValue
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: * Show all the invalid properties with reasons.
275: *
276: * @return array invalid properties with reasons
277: */
278: public function listInvalidProperties()
279: {
280: $invalidProperties = [];
281:
282: return $invalidProperties;
283: }
284:
285: /**
286: * Validate all the properties in the model
287: * return true if all passed
288: *
289: * @return bool True if all properties are valid
290: */
291: public function valid()
292: {
293: return count($this->listInvalidProperties()) === 0;
294: }
295:
296:
297: /**
298: * Gets code
299: *
300: * @return int|null
301: */
302: public function getCode()
303: {
304: return $this->container['code'];
305: }
306:
307: /**
308: * Sets code
309: *
310: * @param int|null $code code
311: *
312: * @return self
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: * Gets type
328: *
329: * @return string|null
330: */
331: public function getType()
332: {
333: return $this->container['type'];
334: }
335:
336: /**
337: * Sets type
338: *
339: * @param string|null $type type
340: *
341: * @return self
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: * Gets message
357: *
358: * @return string|null
359: */
360: public function getMessage()
361: {
362: return $this->container['message'];
363: }
364:
365: /**
366: * Sets message
367: *
368: * @param string|null $message message
369: *
370: * @return self
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: * Returns true if offset exists. False otherwise.
385: *
386: * @param integer $offset Offset
387: *
388: * @return boolean
389: */
390: public function offsetExists($offset): bool
391: {
392: return isset($this->container[$offset]);
393: }
394:
395: /**
396: * Gets offset.
397: *
398: * @param integer $offset Offset
399: *
400: * @return mixed|null
401: */
402: #[\ReturnTypeWillChange]
403: public function offsetGet($offset)
404: {
405: return $this->container[$offset] ?? null;
406: }
407:
408: /**
409: * Sets value based on offset.
410: *
411: * @param int|null $offset Offset
412: * @param mixed $value Value to be set
413: *
414: * @return void
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: * Unsets offset.
427: *
428: * @param integer $offset Offset
429: *
430: * @return void
431: */
432: public function offsetUnset($offset): void
433: {
434: unset($this->container[$offset]);
435: }
436:
437: /**
438: * Serializes the object to a value that can be serialized natively by json_encode().
439: * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
440: *
441: * @return mixed Returns data which can be serialized by json_encode(), which is a value
442: * of any type other than a resource.
443: */
444: #[\ReturnTypeWillChange]
445: public function jsonSerialize()
446: {
447: return ObjectSerializer::sanitizeForSerialization($this);
448: }
449:
450: /**
451: * Gets the string presentation of the object
452: *
453: * @return string
454: */
455: public function __toString()
456: {
457: return json_encode(
458: ObjectSerializer::sanitizeForSerialization($this),
459: JSON_PRETTY_PRINT
460: );
461: }
462:
463: /**
464: * Gets a header-safe presentation of the object
465: *
466: * @return string
467: */
468: public function toHeaderValue()
469: {
470: return json_encode(ObjectSerializer::sanitizeForSerialization($this));
471: }
472: }
473:
474:
475: