1 | <?php |
||
18 | class Types |
||
19 | { |
||
20 | const TYPE_ARRAY = 'array'; |
||
21 | const TYPE_BOOLEAN = 'boolean'; |
||
22 | const TYPE_INTEGER = 'integer'; |
||
23 | const TYPE_NUMBER = 'number'; |
||
24 | const TYPE_NULL = 'null'; |
||
25 | const TYPE_OBJECT = 'object'; |
||
26 | const TYPE_STRING = 'string'; |
||
27 | |||
28 | /** |
||
29 | * Returns the type of an instance according to JSON Schema Core 3.5. |
||
30 | * |
||
31 | * @param mixed $instance |
||
32 | * |
||
33 | * @return string |
||
34 | * |
||
35 | * @throws UnsupportedTypeException |
||
36 | */ |
||
37 | 356 | public static function getPrimitiveTypeOf($instance) |
|
60 | |||
61 | /** |
||
62 | * Returns whether an instance matches a given type. |
||
63 | * |
||
64 | * @param mixed $instance |
||
65 | * @param string $type |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | 260 | public static function isA($instance, $type) |
|
92 | |||
93 | /** |
||
94 | * Returns whether a type is part of the list of primitive types |
||
95 | * defined by the specification. |
||
96 | * |
||
97 | * @param string $type |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | 204 | public static function isPrimitive($type) |
|
111 | } |
||
112 |