@@ -11,10 +11,10 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Prevent direct file access |
14 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
14 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Prevent loading the library more than once |
18 | 18 | */ |
19 | -if( defined( 'AMARKAL_VALIDATION' ) ) return false; |
|
20 | -define( 'AMARKAL_VALIDATION', true ); |
|
21 | 19 | \ No newline at end of file |
20 | +if (defined('AMARKAL_VALIDATION')) return false; |
|
21 | +define('AMARKAL_VALIDATION', true); |
|
22 | 22 | \ No newline at end of file |
@@ -16,5 +16,7 @@ |
||
16 | 16 | /** |
17 | 17 | * Prevent loading the library more than once |
18 | 18 | */ |
19 | -if( defined( 'AMARKAL_VALIDATION' ) ) return false; |
|
19 | +if( defined( 'AMARKAL_VALIDATION' ) ) { |
|
20 | + return false; |
|
21 | +} |
|
20 | 22 | define( 'AMARKAL_VALIDATION', true ); |
21 | 23 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | // Load module functions |
12 | 12 | require_once 'functions.php'; |
@@ -19,16 +19,28 @@ |
||
19 | 19 | return \is_float($num); |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param integer $num |
|
24 | + * @param integer $limit |
|
25 | + */ |
|
22 | 26 | static function less_than( $num, $limit ) |
23 | 27 | { |
24 | 28 | return self::is_numeric($num) && $num < $limit; |
25 | 29 | } |
26 | 30 | |
31 | + /** |
|
32 | + * @param integer $num |
|
33 | + * @param integer $limit |
|
34 | + */ |
|
27 | 35 | static function greater_than( $num, $limit ) |
28 | 36 | { |
29 | 37 | return self::is_numeric($num) && $num > $limit; |
30 | 38 | } |
31 | 39 | |
40 | + /** |
|
41 | + * @param integer $min |
|
42 | + * @param integer $max |
|
43 | + */ |
|
32 | 44 | static function in_range( $num, $min, $max, $inclusive = false ) |
33 | 45 | { |
34 | 46 | if($inclusive) |
@@ -4,34 +4,34 @@ |
||
4 | 4 | |
5 | 5 | class Number |
6 | 6 | { |
7 | - static function is_numeric( $num ) |
|
7 | + static function is_numeric($num) |
|
8 | 8 | { |
9 | 9 | return \is_numeric($num); |
10 | 10 | } |
11 | 11 | |
12 | - static function is_int( $num ) |
|
12 | + static function is_int($num) |
|
13 | 13 | { |
14 | 14 | return \is_int($num); |
15 | 15 | } |
16 | 16 | |
17 | - static function is_float( $num ) |
|
17 | + static function is_float($num) |
|
18 | 18 | { |
19 | 19 | return \is_float($num); |
20 | 20 | } |
21 | 21 | |
22 | - static function less_than( $num, $limit ) |
|
22 | + static function less_than($num, $limit) |
|
23 | 23 | { |
24 | 24 | return self::is_numeric($num) && $num < $limit; |
25 | 25 | } |
26 | 26 | |
27 | - static function greater_than( $num, $limit ) |
|
27 | + static function greater_than($num, $limit) |
|
28 | 28 | { |
29 | 29 | return self::is_numeric($num) && $num > $limit; |
30 | 30 | } |
31 | 31 | |
32 | - static function in_range( $num, $min, $max, $inclusive = false ) |
|
32 | + static function in_range($num, $min, $max, $inclusive = false) |
|
33 | 33 | { |
34 | - if($inclusive) |
|
34 | + if ($inclusive) |
|
35 | 35 | { |
36 | 36 | return self::is_numeric($num) && $num <= $max && $num >= $min; |
37 | 37 | } |
@@ -4,16 +4,28 @@ |
||
4 | 4 | |
5 | 5 | class Strings |
6 | 6 | { |
7 | + /** |
|
8 | + * @param string $str |
|
9 | + * @param integer $length |
|
10 | + */ |
|
7 | 11 | static function length_less_than( $str, $length ) |
8 | 12 | { |
9 | 13 | return strlen($str) < $length; |
10 | 14 | } |
11 | 15 | |
16 | + /** |
|
17 | + * @param string $str |
|
18 | + * @param integer $length |
|
19 | + */ |
|
12 | 20 | static function length_greater_than( $str, $length ) |
13 | 21 | { |
14 | 22 | return strlen($str) > $length; |
15 | 23 | } |
16 | 24 | |
25 | + /** |
|
26 | + * @param string $str |
|
27 | + * @param string $regex |
|
28 | + */ |
|
17 | 29 | static function match( $str, $regex ) |
18 | 30 | { |
19 | 31 | return preg_match($regex, $str) === 1; |
@@ -4,23 +4,23 @@ |
||
4 | 4 | |
5 | 5 | class Strings |
6 | 6 | { |
7 | - static function length_less_than( $str, $length ) |
|
7 | + static function length_less_than($str, $length) |
|
8 | 8 | { |
9 | 9 | return strlen($str) < $length; |
10 | 10 | } |
11 | 11 | |
12 | - static function length_greater_than( $str, $length ) |
|
12 | + static function length_greater_than($str, $length) |
|
13 | 13 | { |
14 | 14 | return strlen($str) > $length; |
15 | 15 | } |
16 | 16 | |
17 | - static function match( $str, $regex ) |
|
17 | + static function match($str, $regex) |
|
18 | 18 | { |
19 | 19 | return preg_match($regex, $str) === 1; |
20 | 20 | } |
21 | 21 | |
22 | - static function is_email( $str ) |
|
22 | + static function is_email($str) |
|
23 | 23 | { |
24 | - return \is_email( $str ) !== false; |
|
24 | + return \is_email($str) !== false; |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -6,13 +6,13 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Load module functions. If this amarkal module has not been loaded, |
13 | 13 | * functions.php will not return false. |
14 | 14 | */ |
15 | -if(false !== (require_once 'functions.php')) |
|
15 | +if (false !== (require_once 'functions.php')) |
|
16 | 16 | { |
17 | 17 | // Load required classes if not using composer |
18 | 18 | require_once 'Strings.php'; |