1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | namespace Ally\PetStore\Schema; |
30: | |
31: | use \ArrayAccess; |
32: | use \Ally\PetStore\ObjectSerializer; |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | class Category implements ModelInterface, ArrayAccess, \JsonSerializable |
45: | { |
46: | public const DISCRIMINATOR = null; |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | protected static $openAPIModelName = 'Category'; |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | |
60: | protected static $openAPITypes = [ |
61: | 'id' => 'int', |
62: | 'name' => 'string' |
63: | ]; |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | protected static $openAPIFormats = [ |
73: | 'id' => 'int64', |
74: | 'name' => null |
75: | ]; |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | protected static array $openAPINullables = [ |
83: | 'id' => false, |
84: | 'name' => false |
85: | ]; |
86: | |
87: | |
88: | |
89: | |
90: | |
91: | |
92: | protected array $openAPINullablesSetToNull = []; |
93: | |
94: | |
95: | |
96: | |
97: | |
98: | |
99: | public static function openAPITypes() |
100: | { |
101: | return self::$openAPITypes; |
102: | } |
103: | |
104: | |
105: | |
106: | |
107: | |
108: | |
109: | public static function openAPIFormats() |
110: | { |
111: | return self::$openAPIFormats; |
112: | } |
113: | |
114: | |
115: | |
116: | |
117: | |
118: | |
119: | protected static function openAPINullables(): array |
120: | { |
121: | return self::$openAPINullables; |
122: | } |
123: | |
124: | |
125: | |
126: | |
127: | |
128: | |
129: | private function getOpenAPINullablesSetToNull(): array |
130: | { |
131: | return $this->openAPINullablesSetToNull; |
132: | } |
133: | |
134: | |
135: | |
136: | |
137: | |
138: | |
139: | |
140: | public static function isNullable(string $property): bool |
141: | { |
142: | return self::openAPINullables()[$property] ?? false; |
143: | } |
144: | |
145: | |
146: | |
147: | |
148: | |
149: | |
150: | |
151: | public function isNullableSetToNull(string $property): bool |
152: | { |
153: | return in_array($property, $this->getOpenAPINullablesSetToNull(), true); |
154: | } |
155: | |
156: | |
157: | |
158: | |
159: | |
160: | |
161: | |
162: | protected static $attributeMap = [ |
163: | 'id' => 'id', |
164: | 'name' => 'name' |
165: | ]; |
166: | |
167: | |
168: | |
169: | |
170: | |
171: | |
172: | protected static $setters = [ |
173: | 'id' => 'setId', |
174: | 'name' => 'setName' |
175: | ]; |
176: | |
177: | |
178: | |
179: | |
180: | |
181: | |
182: | protected static $getters = [ |
183: | 'id' => 'getId', |
184: | 'name' => 'getName' |
185: | ]; |
186: | |
187: | |
188: | |
189: | |
190: | |
191: | |
192: | |
193: | public static function attributeMap() |
194: | { |
195: | return self::$attributeMap; |
196: | } |
197: | |
198: | |
199: | |
200: | |
201: | |
202: | |
203: | public static function setters() |
204: | { |
205: | return self::$setters; |
206: | } |
207: | |
208: | |
209: | |
210: | |
211: | |
212: | |
213: | public static function getters() |
214: | { |
215: | return self::$getters; |
216: | } |
217: | |
218: | |
219: | |
220: | |
221: | |
222: | |
223: | public function getModelName() |
224: | { |
225: | return self::$openAPIModelName; |
226: | } |
227: | |
228: | |
229: | |
230: | |
231: | |
232: | |
233: | |
234: | protected $container = []; |
235: | |
236: | |
237: | |
238: | |
239: | |
240: | |
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: | |
250: | |
251: | |
252: | |
253: | |
254: | |
255: | |
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: | |
268: | |
269: | |
270: | |
271: | public function listInvalidProperties() |
272: | { |
273: | $invalidProperties = []; |
274: | |
275: | if (!is_null($this->container['name']) && !preg_match("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/", $this->container['name'])) { |
276: | $invalidProperties[] = "invalid value for 'name', must be conform to the pattern /^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/."; |
277: | } |
278: | |
279: | return $invalidProperties; |
280: | } |
281: | |
282: | |
283: | |
284: | |
285: | |
286: | |
287: | |
288: | public function valid() |
289: | { |
290: | return count($this->listInvalidProperties()) === 0; |
291: | } |
292: | |
293: | |
294: | |
295: | |
296: | |
297: | |
298: | |
299: | public function getId() |
300: | { |
301: | return $this->container['id']; |
302: | } |
303: | |
304: | |
305: | |
306: | |
307: | |
308: | |
309: | |
310: | |
311: | public function setId($id) |
312: | { |
313: | |
314: | if (is_null($id)) { |
315: | throw new \InvalidArgumentException('non-nullable id cannot be null'); |
316: | } |
317: | |
318: | $this->container['id'] = $id; |
319: | |
320: | return $this; |
321: | } |
322: | |
323: | |
324: | |
325: | |
326: | |
327: | |
328: | public function getName() |
329: | { |
330: | return $this->container['name']; |
331: | } |
332: | |
333: | |
334: | |
335: | |
336: | |
337: | |
338: | |
339: | |
340: | public function setName($name) |
341: | { |
342: | |
343: | if (!is_null($name) && (!preg_match("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/", $name))) { |
344: | throw new \InvalidArgumentException("invalid value for \$name when calling Category., must conform to the pattern /^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/."); |
345: | } |
346: | |
347: | |
348: | if (is_null($name)) { |
349: | throw new \InvalidArgumentException('non-nullable name cannot be null'); |
350: | } |
351: | |
352: | $this->container['name'] = $name; |
353: | |
354: | return $this; |
355: | } |
356: | |
357: | |
358: | |
359: | |
360: | |
361: | |
362: | |
363: | public function offsetExists($offset): bool |
364: | { |
365: | return isset($this->container[$offset]); |
366: | } |
367: | |
368: | |
369: | |
370: | |
371: | |
372: | |
373: | |
374: | |
375: | #[\ReturnTypeWillChange] |
376: | public function offsetGet($offset) |
377: | { |
378: | return $this->container[$offset] ?? null; |
379: | } |
380: | |
381: | |
382: | |
383: | |
384: | |
385: | |
386: | |
387: | |
388: | |
389: | public function offsetSet($offset, $value): void |
390: | { |
391: | if (is_null($offset)) { |
392: | $this->container[] = $value; |
393: | } else { |
394: | $this->container[$offset] = $value; |
395: | } |
396: | } |
397: | |
398: | |
399: | |
400: | |
401: | |
402: | |
403: | |
404: | |
405: | public function offsetUnset($offset): void |
406: | { |
407: | unset($this->container[$offset]); |
408: | } |
409: | |
410: | |
411: | |
412: | |
413: | |
414: | |
415: | |
416: | |
417: | #[\ReturnTypeWillChange] |
418: | public function jsonSerialize() |
419: | { |
420: | return ObjectSerializer::sanitizeForSerialization($this); |
421: | } |
422: | |
423: | |
424: | |
425: | |
426: | |
427: | |
428: | public function __toString() |
429: | { |
430: | return json_encode( |
431: | ObjectSerializer::sanitizeForSerialization($this), |
432: | JSON_PRETTY_PRINT |
433: | ); |
434: | } |
435: | |
436: | |
437: | |
438: | |
439: | |
440: | |
441: | public function toHeaderValue() |
442: | { |
443: | return json_encode(ObjectSerializer::sanitizeForSerialization($this)); |
444: | } |
445: | } |
446: | |
447: | |
448: | |