@@ -27,9 +27,9 @@ |
||
27 | 27 | |
28 | 28 | interface Validator_Base { |
29 | 29 | |
30 | - public function isValide ($value) : bool; |
|
30 | + public function isValide($value) : bool; |
|
31 | 31 | |
32 | - public function validate ($value); |
|
32 | + public function validate($value); |
|
33 | 33 | |
34 | 34 | } |
35 | 35 |
@@ -39,12 +39,12 @@ |
||
39 | 39 | //$value = Database::getInstance()->escape($value); |
40 | 40 | |
41 | 41 | //remove html entities |
42 | - $value = htmlspecialchars($value, ENT_QUOTES, "UTF-8");//htmlentities($value, null, "UTF-8"); |
|
42 | + $value = htmlspecialchars($value, ENT_QUOTES, "UTF-8"); //htmlentities($value, null, "UTF-8"); |
|
43 | 43 | |
44 | 44 | return $value; |
45 | 45 | } |
46 | 46 | |
47 | - public static function get (string $value) : string { |
|
47 | + public static function get(string $value) : string { |
|
48 | 48 | $obj = new Validator_String(); |
49 | 49 | return $obj->validate($value); |
50 | 50 | } |
@@ -27,16 +27,16 @@ |
||
27 | 27 | |
28 | 28 | class Validator_Filename implements Validator_Base { |
29 | 29 | |
30 | - public function isValide ($value): bool { |
|
30 | + public function isValide($value): bool { |
|
31 | 31 | return ctype_alnum($value); |
32 | 32 | } |
33 | 33 | |
34 | - public function validate ($value) : string { |
|
34 | + public function validate($value) : string { |
|
35 | 35 | //remove all characters except except a-z, A-Z and 0-9 |
36 | 36 | return preg_replace("/[^a-zA-Z0-9]+/", "", $value); |
37 | 37 | } |
38 | 38 | |
39 | - public static function get (string $value) : string { |
|
39 | + public static function get(string $value) : string { |
|
40 | 40 | $obj = new Validator_Filename(); |
41 | 41 | return $obj->validate($value); |
42 | 42 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | |
30 | 30 | //https://code.hyperspatial.com/all-code/php-code/verify-hex-color-string/ |
31 | 31 | |
32 | - public function isValide ($value): bool { |
|
33 | - if(preg_match('/^#[a-f0-9]{6}$/i', $value)) { //hex color is valid |
|
32 | + public function isValide($value): bool { |
|
33 | + if (preg_match('/^#[a-f0-9]{6}$/i', $value)) { //hex color is valid |
|
34 | 34 | //Verified hex color |
35 | 35 | return true; |
36 | - } else if(preg_match('/^[a-f0-9]{6}$/i', $value)) { |
|
36 | + } else if (preg_match('/^[a-f0-9]{6}$/i', $value)) { |
|
37 | 37 | //Check for a hex color string without hash 'c1c2b4' |
38 | 38 | //hex color is valid |
39 | 39 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | - public function validate ($value) { |
|
49 | - if(preg_match('/^#[a-f0-9]{6}$/i', $value)) { //hex color is valid |
|
48 | + public function validate($value) { |
|
49 | + if (preg_match('/^#[a-f0-9]{6}$/i', $value)) { //hex color is valid |
|
50 | 50 | //Verified hex color |
51 | 51 | return $value; |
52 | - } else if(preg_match('/^[a-f0-9]{6}$/i', $value)) { |
|
52 | + } else if (preg_match('/^[a-f0-9]{6}$/i', $value)) { |
|
53 | 53 | //Check for a hex color string without hash 'c1c2b4' |
54 | 54 | //hex color is valid |
55 | 55 |
@@ -29,16 +29,16 @@ |
||
29 | 29 | |
30 | 30 | protected static $instance = null; |
31 | 31 | |
32 | - public function isValide ($value): bool { |
|
32 | + public function isValide($value): bool { |
|
33 | 33 | return $value === $this->validate($value); |
34 | 34 | } |
35 | 35 | |
36 | - public function validate ($value) : string { |
|
36 | + public function validate($value) : string { |
|
37 | 37 | //remove all characters except except a-z, A-Z and 0-9 |
38 | 38 | return preg_replace("/[^a-zA-Z_0-9]+/", "", $value); |
39 | 39 | } |
40 | 40 | |
41 | - public static function get (string $value) : string { |
|
41 | + public static function get(string $value) : string { |
|
42 | 42 | if (self::$instance == null) { |
43 | 43 | self::$instance = new Validator_Token(); |
44 | 44 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | |
30 | 30 | protected static $instance = null; |
31 | 31 | |
32 | - public function isValide ($value): bool { |
|
32 | + public function isValide($value): bool { |
|
33 | 33 | return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; |
34 | 34 | } |
35 | 35 | |
36 | - public function validate ($value) : string { |
|
36 | + public function validate($value) : string { |
|
37 | 37 | if (!$this->isValide($value)) { |
38 | 38 | throw new SecurityException("given mail '" . htmlentities($value) . "' isnt a valide mail."); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | return filter_var($value, FILTER_VALIDATE_EMAIL); |
42 | 42 | } |
43 | 43 | |
44 | - public static function get (string $value) : string { |
|
44 | + public static function get(string $value) : string { |
|
45 | 45 | if (self::$instance == null) { |
46 | 46 | self::$instance = new Validator_Mail(); |
47 | 47 | } |
@@ -29,16 +29,16 @@ |
||
29 | 29 | |
30 | 30 | protected static $instance = null; |
31 | 31 | |
32 | - public function isValide ($value): bool { |
|
32 | + public function isValide($value): bool { |
|
33 | 33 | return ctype_alnum($value); |
34 | 34 | } |
35 | 35 | |
36 | - public function validate ($value) : string { |
|
36 | + public function validate($value) : string { |
|
37 | 37 | //remove all characters except except a-z, A-Z and 0-9 |
38 | 38 | return preg_replace("/[^a-zA-Z0-9]+/", "", $value); |
39 | 39 | } |
40 | 40 | |
41 | - public static function get (string $value) : string { |
|
41 | + public static function get(string $value) : string { |
|
42 | 42 | if (self::$instance == null) { |
43 | 43 | self::$instance = new Validator_AlphaNumeric(); |
44 | 44 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class SecurityException extends Exception{ |
|
3 | +class SecurityException extends Exception { |
|
4 | 4 | |
5 | 5 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class ConfigurationException extends Exception{ |
|
3 | +class ConfigurationException extends Exception { |
|
4 | 4 | |
5 | 5 | } |