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) |
||
49 | |||
50 | /** |
||
51 | * Check if var is boolean |
||
52 | * |
||
53 | * 1. Do a check if the floatval() is 0, if so it's not a double |
||
54 | * 2. Check if the intval() is the same as the floatval() |
||
55 | * 2a. If they are the same, check if there's a decimal, if so it probably ends in .0 |
||
56 | * |
||
57 | * @param string $var |
||
58 | * @return bool |
||
59 | */ |
||
60 | private static function isDouble($var) |
||
64 | |||
65 | /** |
||
66 | * Check if var is an int |
||
67 | * |
||
68 | * Only does an extra check for 0 after cast |
||
69 | * |
||
70 | * @param string $var |
||
71 | * @return bool |
||
72 | */ |
||
73 | private static function isInt($var) |
||
77 | |||
78 | /** |
||
79 | * Check if 'true' or 'false' is that value of var |
||
80 | * |
||
81 | * @param string $var |
||
82 | * @return bool |
||
83 | */ |
||
84 | private static function isBool($var) |
||
92 | } |
||
93 |