BulkUpdater work.
[order_line_extra.git] / hincludes / lib / Std.class.php
1 <?php
2
3 class Std {
4         public function __construct(){}
5         static function is($v, $t) {
6                 return _hx_instanceof($v, $t);
7         }
8         static function string($s) {
9                 return _hx_string_rec($s, "");
10         }
11         static function int($x) {
12                 return intval($x);
13         }
14         static function parseInt($x) {
15                 if(!is_numeric($x)) {
16                         $matches = null;
17                         preg_match("/^-?\\d+/", $x, $matches);
18                         return ((count($matches) === 0) ? null : intval($matches[0]));
19                 } else {
20                         return ((strtolower(_hx_substr($x, 0, 2)) === "0x") ? (int) hexdec(substr($x, 2)) : intval($x));
21                 }
22         }
23         static function parseFloat($x) {
24                 $v = floatval($x);
25                 if($v === 0.0) {
26                         $x = rtrim($x);
27                         $v = floatval($x);
28                         if($v === 0.0 && !is_numeric($x)) {
29                                 $v = acos(1.01);
30                         }
31                 }
32                 return $v;
33         }
34         static function random($x) {
35                 return mt_rand(0, $x - 1);
36         }
37         function __toString() { return 'Std'; }
38 }