sonar resolve bugs
continuous-integration/drone/push Build is passing Details

LoginModification
alexi 2 years ago
parent f2853c65f6
commit dd0eec1970

@ -11,7 +11,7 @@ class Clean
* @return string La chaîne nettoyée * @return string La chaîne nettoyée
*/ */
static function simpleString(string $string): string public static function simpleString(string $string): string
{ {
$string = trim($string); $string = trim($string);
$string = strip_tags($string); $string = strip_tags($string);
@ -25,7 +25,7 @@ class Clean
* @return string La chaîne nettoyée * @return string La chaîne nettoyée
*/ */
static function email($email): string public static function email($email): string
{ {
$email = self::simpleString($email); $email = self::simpleString($email);
return filter_var($email, FILTER_SANITIZE_EMAIL); return filter_var($email, FILTER_SANITIZE_EMAIL);
@ -38,8 +38,8 @@ class Clean
* @return int Le nombre entier formaté * @return int Le nombre entier formaté
*/ */
static function int(int $int): int public static function int(int $int): int
{ {
return filter_var($int, FILTER_SANITIZE_NUMBER_INT); return filter_var($int, FILTER_SANITIZE_NUMBER_INT);
} }
} }

@ -11,13 +11,10 @@ class Validate
* @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon. * @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon.
*/ */
static function email (String $email): bool public static function email (String $email): bool
{ {
global $emailMaxLength; global $emailMaxLength;
if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength){ return (filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength);
return true;
}
else return false;
} }
/** /**
@ -28,13 +25,10 @@ class Validate
* @return bool Vrai si le pseudo est valide, faux sinon. * @return bool Vrai si le pseudo est valide, faux sinon.
*/ */
static function pseudo(string $pseudo) : bool public static function pseudo(string $pseudo) : bool
{ {
global $pseudoMaxLength; global $pseudoMaxLength;
if(strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){ return (strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength);
return true;
}
else return false;
} }
/** /**
@ -45,13 +39,10 @@ class Validate
* @return bool Vrai si le mot de passe est valide, faux sinon. * @return bool Vrai si le mot de passe est valide, faux sinon.
*/ */
static function password(string $password) : bool public static function password(string $password) : bool
{ {
global $passwordMaxLength; global $passwordMaxLength;
if(strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password)){ return (strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password));
return true;
}
else return false;
} }
/** /**
@ -61,12 +52,10 @@ class Validate
* @return bool Vrai si le mot-clé est valide, faux sinon. * @return bool Vrai si le mot-clé est valide, faux sinon.
*/ */
static function keyWord(string $keyword) : bool public static function keyWord(string $keyword) : bool
{ {
global $keyWordMaxLength; global $keyWordMaxLength;
if (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3) return (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3);
return true;
else return false;
} }
/** /**
@ -76,12 +65,10 @@ class Validate
* @return bool Vrai si le titre est valide, faux sinon. * @return bool Vrai si le titre est valide, faux sinon.
*/ */
static function title(string $title) : bool public static function title(string $title) : bool
{ {
global $titleMaxLength; global $titleMaxLength;
if (strlen($title) <= $titleMaxLength && strlen($title) >= 3) return (strlen($title) <= $titleMaxLength && strlen($title) >= 3);
return true;
else return false;
} }
/** /**
@ -91,12 +78,10 @@ class Validate
* @return bool Vrai si le type est valide, faux sinon. * @return bool Vrai si le type est valide, faux sinon.
*/ */
static function type(string $type) : bool public static function type(string $type) : bool
{ {
global $typeMaxLength; global $typeMaxLength;
if (strlen($type) <= $typeMaxLength && strlen($type) >=3) return (strlen($type) <= $typeMaxLength && strlen($type) >=3);
return true;
else return false;
} }
/** /**
@ -106,10 +91,8 @@ class Validate
* @return bool Vrai si la réponse est valide, faux sinon. * @return bool Vrai si la réponse est valide, faux sinon.
*/ */
static function response(string $response) : bool{ public static function response(string $response) : bool{
global $responseMaxLength; global $responseMaxLength;
if(strlen($response) <= $responseMaxLength) return (strlen($response) <= $responseMaxLength);
return true;
else return false;
} }
} }

Loading…
Cancel
Save