1 | <?php |
||
14 | class Realtype |
||
15 | { |
||
16 | /** |
||
17 | * Get the real type from a string |
||
18 | * |
||
19 | * @param string $var |
||
20 | * @return bool|float|int|string |
||
21 | */ |
||
22 | public static function get($var) |
||
53 | |||
54 | /** |
||
55 | * Check if var is boolean |
||
56 | * |
||
57 | * 1. Do a check if the floatval() is 0, if so it's not a double |
||
58 | * 2. Check if the intval() is the same as the floatval() |
||
59 | * 2a. If they are the same, check if there's a decimal, if so it probably ends in .0 |
||
60 | * |
||
61 | * @param string $var |
||
62 | * @return bool |
||
63 | */ |
||
64 | private static function isDouble($var) |
||
68 | |||
69 | /** |
||
70 | * Check if var is an int |
||
71 | * |
||
72 | * Only does an extra check for 0 after cast |
||
73 | * |
||
74 | * @param string $var |
||
75 | * @return bool |
||
76 | */ |
||
77 | private static function isInt($var) |
||
81 | |||
82 | /** |
||
83 | * Check if 'true' or 'false' is that value of var |
||
84 | * |
||
85 | * @param string $var |
||
86 | * @return bool |
||
87 | */ |
||
88 | private static function isBool($var) |
||
92 | |||
93 | /** |
||
94 | * Check if var is null |
||
95 | * |
||
96 | * @param string $var |
||
97 | * @return bool |
||
98 | */ |
||
99 | private static function isNull($var) |
||
103 | } |
||
104 |