1 | <?php |
||
5 | abstract class Schema |
||
6 | { |
||
7 | protected const SCHEMA_TYPES = [ |
||
8 | 'array', |
||
9 | 'boolean', |
||
10 | 'integer', |
||
11 | 'null', |
||
12 | 'number', |
||
13 | 'object', |
||
14 | 'string' |
||
15 | ]; |
||
16 | |||
17 | /** |
||
18 | * @param string $path |
||
19 | * @return static |
||
20 | */ |
||
21 | 2 | public static function fromFile($path): Schema |
|
25 | |||
26 | /** |
||
27 | * @param object $json |
||
28 | */ |
||
29 | 11 | public static function make($json): Schema |
|
46 | |||
47 | /** |
||
48 | * @var object |
||
49 | */ |
||
50 | protected $schema; |
||
51 | |||
52 | 9 | public function __construct($schema) |
|
56 | |||
57 | 9 | public function type(): string |
|
61 | |||
62 | abstract public function phpType(): string; |
||
63 | |||
64 | 3 | public function isArray(): bool |
|
68 | |||
69 | 1 | public function isBoolean(): bool |
|
73 | |||
74 | 2 | public function isInteger(): bool |
|
78 | |||
79 | 2 | public function isNull(): bool |
|
83 | |||
84 | 1 | public function isNumber(): bool |
|
88 | |||
89 | 3 | public function isObject(): bool |
|
93 | |||
94 | 3 | public function isString(): bool |
|
98 | |||
99 | 1 | public function title(): string |
|
103 | } |
||
104 |