@@ -32,7 +32,7 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | 37 | if (is_numeric($value) && is_int($value)) { |
38 | 38 | return true; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use app\framework\Component\Validation\ValidationException; |
12 | 12 | use app\framework\Component\Validation\ValidatorInterface; |
13 | 13 | |
14 | -class Email implements ValidatorInterface{ |
|
14 | +class Email implements ValidatorInterface { |
|
15 | 15 | /** |
16 | 16 | * Get validator name, eg: email |
17 | 17 | * |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return boolean|string |
33 | 33 | */ |
34 | - public function validate($value, $params = [], $throw = true) |
|
34 | + public function validate($value, $params = [ ], $throw = true) |
|
35 | 35 | { |
36 | 36 | if (filter_var($value, FILTER_VALIDATE_EMAIL)) { |
37 | 37 | return true; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | 37 | if (preg_match_all("/^[-+0-9()]+$/", $value)) { |
38 | 38 | return true; |
@@ -32,15 +32,15 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | - $cmp = $params[0]; |
|
38 | - if($value > $cmp){ |
|
37 | + $cmp = $params[ 0 ]; |
|
38 | + if ($value > $cmp) { |
|
39 | 39 | return true; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $message = "Value must be greater than %s"; |
43 | - if($throw){ |
|
43 | + if ($throw) { |
|
44 | 44 | throw (new ValidationException($message, $cmp)); |
45 | 45 | } |
46 | 46 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | 37 | if (!(is_null($value) || $value === '')) { |
38 | 38 | return true; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = false) |
|
35 | + public function validate($value, $params = [ ], $throw = false) |
|
36 | 36 | { |
37 | 37 | $cardArray = [ |
38 | 38 | 'default' => [ |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Check card type |
97 | 97 | $type = strtolower($type); |
98 | 98 | |
99 | - if (!isset($cards[$type])) { |
|
99 | + if (!isset($cards[ $type ])) { |
|
100 | 100 | if ($throw) { |
101 | 101 | throw (new ValidationException($message)); |
102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $length = strlen($number); |
109 | 109 | |
110 | 110 | // Validate the card length by the card type |
111 | - if (!in_array($length, preg_split('/\D+/', $cards[$type]['length']))) { |
|
111 | + if (!in_array($length, preg_split('/\D+/', $cards[ $type ][ 'length' ]))) { |
|
112 | 112 | if ($throw) { |
113 | 113 | throw (new ValidationException($message)); |
114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Check card number prefix |
120 | - if (!preg_match('/^' . $cards[$type]['prefix'] . '/', $number)) { |
|
120 | + if (!preg_match('/^'.$cards[ $type ][ 'prefix' ].'/', $number)) { |
|
121 | 121 | if ($throw) { |
122 | 122 | throw (new ValidationException($message)); |
123 | 123 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // No Luhn check required |
129 | - if ($cards[$type]['luhn'] == false) { |
|
129 | + if ($cards[ $type ][ 'luhn' ] == false) { |
|
130 | 130 | return true; |
131 | 131 | } |
132 | 132 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | // Force the value to be a string as this method uses string functions. |
147 | 147 | // Converting to an integer may pass PHP_INT_MAX and result in an error! |
148 | - $number = (string)$number; |
|
148 | + $number = (string) $number; |
|
149 | 149 | |
150 | 150 | if (!ctype_digit($number)) { |
151 | 151 | // Luhn can only be used on numbers! |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | 37 | if (is_numeric($value)) { |
38 | 38 | return true; |
@@ -32,15 +32,15 @@ |
||
32 | 32 | * |
33 | 33 | * @return boolean|string |
34 | 34 | */ |
35 | - public function validate($value, $params = [], $throw = true) |
|
35 | + public function validate($value, $params = [ ], $throw = true) |
|
36 | 36 | { |
37 | - $cmp = $params[0]; |
|
38 | - if($value < $cmp){ |
|
37 | + $cmp = $params[ 0 ]; |
|
38 | + if ($value < $cmp) { |
|
39 | 39 | return true; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $message = "Value must be less than %s"; |
43 | - if($throw){ |
|
43 | + if ($throw) { |
|
44 | 44 | throw (new ValidationException($message, $cmp)); |
45 | 45 | } |
46 | 46 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @return boolean|string |
35 | 35 | */ |
36 | - public function validate($value, $params = [], $throw = true) |
|
36 | + public function validate($value, $params = [ ], $throw = true) |
|
37 | 37 | { |
38 | 38 | if (filter_var($value, FILTER_VALIDATE_URL)) { |
39 | 39 | return true; |