File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 32
32
},
33
33
"files" : [
34
34
" xwp-helper-fns.php" ,
35
+ " xwp-helper-fns-num.php" ,
35
36
" xwp-helper-fns-req.php"
36
37
]
37
38
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Numeric functions and helpers
4
+ *
5
+ * @package eXtended WordPress
6
+ * @subpackage Functions
7
+ */
8
+
9
+ if ( ! function_exists ( 'xwp_is_float_str ' ) ) :
10
+
11
+ /**
12
+ * Check if a string is a integer
13
+ *
14
+ * @param mixed $str The string to check.
15
+ * @return bool
16
+ */
17
+ function xwp_is_int_str ( mixed $ str ): bool {
18
+ if ( is_int ( $ str ) ) {
19
+ return true ;
20
+ }
21
+
22
+ return is_string ( $ str ) && ctype_digit ( strval ( abs ( $ str ) ) );
23
+ }
24
+
25
+ endif ;
26
+
27
+ if ( ! function_exists ( 'xwp_is_float_str ' ) ) :
28
+
29
+ /**
30
+ * Check if a string is a float
31
+ *
32
+ * @param mixed $str The string to check.
33
+ * @return bool
34
+ */
35
+ function xwp_is_float_str ( mixed $ str ): bool {
36
+ if ( is_float ( $ str ) ) {
37
+ return true ;
38
+ }
39
+
40
+ return is_numeric ( $ str ) && ( (string ) (float ) $ str ) === $ str ;
41
+ }
42
+
43
+ endif ;
You can’t perform that action at this time.
0 commit comments