1 | <?php declare(strict_types=1); |
||
19 | abstract class Schema implements Element |
||
20 | { |
||
21 | use VisiteeMixin; |
||
22 | |||
23 | const TYPE_ANY = 'any'; |
||
24 | const TYPE_ARRAY = 'array'; |
||
25 | const TYPE_BOOL = 'boolean'; |
||
26 | const TYPE_INT = 'integer'; |
||
27 | const TYPE_NUMBER = 'number'; |
||
28 | const TYPE_NULL = 'null'; |
||
29 | const TYPE_OBJECT = 'object'; |
||
30 | const TYPE_STRING = 'string'; |
||
31 | |||
32 | const FORMAT_DATE = 'date'; |
||
33 | const FORMAT_DATE_TIME = 'date-time'; |
||
34 | |||
35 | const FORMAT_INT32 = 'int32'; |
||
36 | const FORMAT_INT64 = 'int64'; |
||
37 | |||
38 | /** |
||
39 | * @var \stdClass |
||
40 | */ |
||
41 | protected $definition; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $type; |
||
47 | |||
48 | /** |
||
49 | * @var mixed |
||
50 | */ |
||
51 | protected $default; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $title = ''; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $description = ''; |
||
62 | |||
63 | /** |
||
64 | * @var bool |
||
65 | */ |
||
66 | protected $readOnly = false; |
||
67 | |||
68 | /** |
||
69 | * @var bool |
||
70 | */ |
||
71 | protected $writeOnly = false; |
||
72 | |||
73 | /** |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $examples = []; |
||
77 | |||
78 | /** |
||
79 | * Schema constructor. |
||
80 | * |
||
81 | * @param \stdClass $definition |
||
82 | */ |
||
83 | public function __construct(\stdClass $definition) |
||
92 | |||
93 | /** |
||
94 | * @return mixed |
||
95 | */ |
||
96 | public function getDefault() |
||
100 | |||
101 | /** |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getTitle(): string |
||
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getDescription(): string |
||
116 | |||
117 | /** |
||
118 | * @return bool |
||
119 | */ |
||
120 | public function isReadOnly(): bool |
||
124 | |||
125 | /** |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function isWriteOnly(): bool |
||
132 | |||
133 | /** |
||
134 | * @return array |
||
135 | */ |
||
136 | public function getExamples(): array |
||
140 | |||
141 | /** |
||
142 | * @param string $type |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isPrimitive(string $type): bool |
||
150 | |||
151 | /** |
||
152 | * @return string |
||
153 | */ |
||
154 | public function getType(): string |
||
158 | |||
159 | /** |
||
160 | * @return \stdClass |
||
161 | */ |
||
162 | public function getDefinition() |
||
166 | |||
167 | /** |
||
168 | * @param string $type |
||
169 | * |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public function isType($type) |
||
176 | } |
||
177 |