PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | classes/utilities.class.php +58 -35 1.3.172.12.4 View file →
@@ -1,35 +1,58 @@
1 -<?php
2 -class WCUtils
3 -{
4 - static function is_blank($val, $strict=false){
5 -
6 - if ( !is_scalar($val) && NULL != $val ){
7 - trigger_error("Value is not a scalar", E_USER_NOTICE);
8 - return true;
9 - }
10 -
11 - if($strict)
12 - $val = preg_replace("/ /", "", $val);
13 -
14 - $val = trim($val);
15 - if ( strlen($val) > 0 )
16 - return false;
17 - else
18 - return true;
19 - }
20 -
21 - static function is_zero($val){
22 -
23 - if ( !is_scalar($val) && NULL != $val ){
24 - trigger_error("Value is not a scalar", E_USER_NOTICE);
25 - return false;
26 - }
27 -
28 - $val = trim($val);
29 - if( !WCUtils::is_blank($val) && is_numeric($val) && 1 === strlen($val) && 0 === (int)$val )
30 - return true;
31 - else
32 - return false;
33 - }
34 -}
35 -?>
1 +<?php
2 +/**
3 + * Utilities class
4 + *
5 + * @package Welcart
6 + */
7 +class WCUtils {
8 +
9 + /**
10 + * Is blank.
11 + *
12 + * @param mixed $val Value.
13 + * @param bool $strict Strict.
14 + * @return bool
15 + */
16 + public static function is_blank( $val, $strict = false ) {
17 + if ( is_null( $val ) ) {
18 + return true;
19 + }
20 +
21 + if ( ! is_scalar( $val ) && ! is_null( $val ) ) {
22 + trigger_error( 'Value is not a scalar', E_USER_NOTICE );
23 + return true;
24 + }
25 +
26 + if ( $strict ) {
27 + $val = preg_replace( '/ /', '', $val );
28 + }
29 +
30 + $val = trim( $val );
31 + if ( strlen( $val ) > 0 ) {
32 + return false;
33 + } else {
34 + return true;
35 + }
36 + }
37 +
38 + /**
39 + * Is zero.
40 + *
41 + * @param mixed $val Value.
42 + * @return bool
43 + */
44 + public static function is_zero( $val ) {
45 +
46 + if ( ! is_scalar( $val ) && ! is_null( $val ) ) {
47 + trigger_error( 'Value is not a scalar', E_USER_NOTICE );
48 + return false;
49 + }
50 +
51 + $val = trim( $val );
52 + if ( ! self::is_blank( $val ) && is_numeric( $val ) && 1 === strlen( $val ) && 0 === (int) $val ) {
53 + return true;
54 + } else {
55 + return false;
56 + }
57 + }
58 +}