1 | <?php |
||
7 | class Type |
||
8 | { |
||
9 | public const TYPE_INT = 'int'; |
||
10 | public const TYPE_INTEGER = 'integer'; |
||
11 | public const TYPE_BOOL = 'bool'; |
||
12 | public const TYPE_BOOLEAN = 'boolean'; |
||
13 | public const TYPE_FLOAT = 'float'; |
||
14 | public const TYPE_DOUBLE = 'double'; |
||
15 | public const TYPE_REAL = 'real'; |
||
16 | public const TYPE_STRING = 'string'; |
||
17 | public const TYPE_ARRAY = 'array'; |
||
18 | public const TYPE_OBJECT = 'object'; |
||
19 | |||
20 | public const INTEGER_TYPES = [ |
||
21 | self::TYPE_INT, |
||
22 | self::TYPE_INTEGER, |
||
23 | ]; |
||
24 | |||
25 | public const BOOLEAN_TYPES = [ |
||
26 | self::TYPE_BOOL, |
||
27 | self::TYPE_BOOLEAN, |
||
28 | ]; |
||
29 | |||
30 | public const FLOAT_TYPES = [ |
||
31 | self::TYPE_FLOAT, |
||
32 | self::TYPE_DOUBLE, |
||
33 | self::TYPE_REAL, |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @param string $type |
||
38 | * @param mixed $value |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public static function cast(string $type, $value) |
||
69 | |||
70 | public static function isValidType(string $type): bool |
||
85 | } |
||
86 |