1 | <?php declare(strict_types = 1); |
||
18 | abstract class Schema implements Element |
||
19 | { |
||
20 | use VisiteeMixin; |
||
21 | |||
22 | const TYPE_ANY = 'any'; |
||
23 | const TYPE_ARRAY = 'array'; |
||
24 | const TYPE_BOOL = 'boolean'; |
||
25 | const TYPE_INT = 'integer'; |
||
26 | const TYPE_NUMBER = 'number'; |
||
27 | const TYPE_NULL = 'null'; |
||
28 | const TYPE_OBJECT = 'object'; |
||
29 | const TYPE_STRING = 'string'; |
||
30 | |||
31 | const FORMAT_DATE = 'date'; |
||
32 | const FORMAT_DATE_TIME = 'date-time'; |
||
33 | |||
34 | const FORMAT_INT32 = 'int32'; |
||
35 | const FORMAT_INT64 = 'int64'; |
||
36 | |||
37 | /** |
||
38 | * @var \stdClass |
||
39 | */ |
||
40 | protected $definition; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $type; |
||
46 | |||
47 | /** |
||
48 | * Schema constructor. |
||
49 | * |
||
50 | * @param \stdClass $definition |
||
51 | */ |
||
52 | public function __construct(\stdClass $definition) |
||
57 | |||
58 | /** |
||
59 | * @param string $type |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function isPrimitive(string $type): bool |
||
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getType(): string |
||
75 | |||
76 | /** |
||
77 | * @return \stdClass |
||
78 | */ |
||
79 | public function getDefinition() |
||
83 | |||
84 | /** |
||
85 | * @param string $type |
||
86 | * |
||
87 | * @return mixed |
||
88 | */ |
||
89 | public function isType($type) |
||
93 | } |
||
94 |