1: <?php
2: /**
3: * Tag
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: * Tag Class Doc Comment
36: *
37: * @category Class
38: * @description A tag for a pet
39: * @package Ally\PetStore
40: * @author OpenAPI Generator team
41: * @link https://openapi-generator.tech
42: * @implements \ArrayAccess<string, mixed>
43: */
44: class Tag 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 = 'Tag';
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: 'name' => 'string'
63: ];
64:
65: /**
66: * Array of property to format mappings. Used for (de)serialization
67: *
68: * @var string[]
69: * @phpstan-var array<string, string|null>
70: * @psalm-var array<string, string|null>
71: */
72: protected static $openAPIFormats = [
73: 'id' => 'int64',
74: 'name' => null
75: ];
76:
77: /**
78: * Array of nullable properties. Used for (de)serialization
79: *
80: * @var boolean[]
81: */
82: protected static array $openAPINullables = [
83: 'id' => false,
84: 'name' => false
85: ];
86:
87: /**
88: * If a nullable field gets set to null, insert it here
89: *
90: * @var boolean[]
91: */
92: protected array $openAPINullablesSetToNull = [];
93:
94: /**
95: * Array of property to type mappings. Used for (de)serialization
96: *
97: * @return array
98: */
99: public static function openAPITypes()
100: {
101: return self::$openAPITypes;
102: }
103:
104: /**
105: * Array of property to format mappings. Used for (de)serialization
106: *
107: * @return array
108: */
109: public static function openAPIFormats()
110: {
111: return self::$openAPIFormats;
112: }
113:
114: /**
115: * Array of nullable properties
116: *
117: * @return array
118: */
119: protected static function openAPINullables(): array
120: {
121: return self::$openAPINullables;
122: }
123:
124: /**
125: * Array of nullable field names deliberately set to null
126: *
127: * @return boolean[]
128: */
129: private function getOpenAPINullablesSetToNull(): array
130: {
131: return $this->openAPINullablesSetToNull;
132: }
133:
134: /**
135: * Checks if a property is nullable
136: *
137: * @param string $property
138: * @return bool
139: */
140: public static function isNullable(string $property): bool
141: {
142: return self::openAPINullables()[$property] ?? false;
143: }
144:
145: /**
146: * Checks if a nullable property is set to null.
147: *
148: * @param string $property
149: * @return bool
150: */
151: public function isNullableSetToNull(string $property): bool
152: {
153: return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
154: }
155:
156: /**
157: * Array of attributes where the key is the local name,
158: * and the value is the original name
159: *
160: * @var string[]
161: */
162: protected static $attributeMap = [
163: 'id' => 'id',
164: 'name' => 'name'
165: ];
166:
167: /**
168: * Array of attributes to setter functions (for deserialization of responses)
169: *
170: * @var string[]
171: */
172: protected static $setters = [
173: 'id' => 'setId',
174: 'name' => 'setName'
175: ];
176:
177: /**
178: * Array of attributes to getter functions (for serialization of requests)
179: *
180: * @var string[]
181: */
182: protected static $getters = [
183: 'id' => 'getId',
184: 'name' => 'getName'
185: ];
186:
187: /**
188: * Array of attributes where the key is the local name,
189: * and the value is the original name
190: *
191: * @return array
192: */
193: public static function attributeMap()
194: {
195: return self::$attributeMap;
196: }
197:
198: /**
199: * Array of attributes to setter functions (for deserialization of responses)
200: *
201: * @return array
202: */
203: public static function setters()
204: {
205: return self::$setters;
206: }
207:
208: /**
209: * Array of attributes to getter functions (for serialization of requests)
210: *
211: * @return array
212: */
213: public static function getters()
214: {
215: return self::$getters;
216: }
217:
218: /**
219: * The original name of the model.
220: *
221: * @return string
222: */
223: public function getModelName()
224: {
225: return self::$openAPIModelName;
226: }
227:
228:
229: /**
230: * Associative array for storing property values
231: *
232: * @var mixed[]
233: */
234: protected $container = [];
235:
236: /**
237: * Constructor
238: *
239: * @param mixed[] $data Associated array of property values
240: * initializing the model
241: */
242: public function __construct(array $data = null)
243: {
244: $this->setIfExists('id', $data ?? [], null);
245: $this->setIfExists('name', $data ?? [], null);
246: }
247:
248: /**
249: * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
250: * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
251: * $this->openAPINullablesSetToNull array
252: *
253: * @param string $variableName
254: * @param array $fields
255: * @param mixed $defaultValue
256: */
257: private function setIfExists(string $variableName, array $fields, $defaultValue): void
258: {
259: if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
260: $this->openAPINullablesSetToNull[] = $variableName;
261: }
262:
263: $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
264: }
265:
266: /**
267: * Show all the invalid properties with reasons.
268: *
269: * @return array invalid properties with reasons
270: */
271: public function listInvalidProperties()
272: {
273: $invalidProperties = [];
274:
275: return $invalidProperties;
276: }
277:
278: /**
279: * Validate all the properties in the model
280: * return true if all passed
281: *
282: * @return bool True if all properties are valid
283: */
284: public function valid()
285: {
286: return count($this->listInvalidProperties()) === 0;
287: }
288:
289:
290: /**
291: * Gets id
292: *
293: * @return int|null
294: */
295: public function getId()
296: {
297: return $this->container['id'];
298: }
299:
300: /**
301: * Sets id
302: *
303: * @param int|null $id id
304: *
305: * @return self
306: */
307: public function setId($id)
308: {
309:
310: if (is_null($id)) {
311: throw new \InvalidArgumentException('non-nullable id cannot be null');
312: }
313:
314: $this->container['id'] = $id;
315:
316: return $this;
317: }
318:
319: /**
320: * Gets name
321: *
322: * @return string|null
323: */
324: public function getName()
325: {
326: return $this->container['name'];
327: }
328:
329: /**
330: * Sets name
331: *
332: * @param string|null $name name
333: *
334: * @return self
335: */
336: public function setName($name)
337: {
338:
339: if (is_null($name)) {
340: throw new \InvalidArgumentException('non-nullable name cannot be null');
341: }
342:
343: $this->container['name'] = $name;
344:
345: return $this;
346: }
347: /**
348: * Returns true if offset exists. False otherwise.
349: *
350: * @param integer $offset Offset
351: *
352: * @return boolean
353: */
354: public function offsetExists($offset): bool
355: {
356: return isset($this->container[$offset]);
357: }
358:
359: /**
360: * Gets offset.
361: *
362: * @param integer $offset Offset
363: *
364: * @return mixed|null
365: */
366: #[\ReturnTypeWillChange]
367: public function offsetGet($offset)
368: {
369: return $this->container[$offset] ?? null;
370: }
371:
372: /**
373: * Sets value based on offset.
374: *
375: * @param int|null $offset Offset
376: * @param mixed $value Value to be set
377: *
378: * @return void
379: */
380: public function offsetSet($offset, $value): void
381: {
382: if (is_null($offset)) {
383: $this->container[] = $value;
384: } else {
385: $this->container[$offset] = $value;
386: }
387: }
388:
389: /**
390: * Unsets offset.
391: *
392: * @param integer $offset Offset
393: *
394: * @return void
395: */
396: public function offsetUnset($offset): void
397: {
398: unset($this->container[$offset]);
399: }
400:
401: /**
402: * Serializes the object to a value that can be serialized natively by json_encode().
403: * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
404: *
405: * @return mixed Returns data which can be serialized by json_encode(), which is a value
406: * of any type other than a resource.
407: */
408: #[\ReturnTypeWillChange]
409: public function jsonSerialize()
410: {
411: return ObjectSerializer::sanitizeForSerialization($this);
412: }
413:
414: /**
415: * Gets the string presentation of the object
416: *
417: * @return string
418: */
419: public function __toString()
420: {
421: return json_encode(
422: ObjectSerializer::sanitizeForSerialization($this),
423: JSON_PRETTY_PRINT
424: );
425: }
426:
427: /**
428: * Gets a header-safe presentation of the object
429: *
430: * @return string
431: */
432: public function toHeaderValue()
433: {
434: return json_encode(ObjectSerializer::sanitizeForSerialization($this));
435: }
436: }
437:
438:
439: