Request class and begin Frontend.
This commit is contained in:
27
src/Helpers/SanitizeTrait.php
Normal file
27
src/Helpers/SanitizeTrait.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
/**
|
||||
* Trait qui permet de désinfecter une variable.
|
||||
*/
|
||||
trait SanitizeTrait {
|
||||
|
||||
/**
|
||||
* Permet de désinfecter une variable
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return mixed
|
||||
*/
|
||||
public static function sanitize( mixed $data ): mixed {
|
||||
|
||||
if( is_string( $data ) ) {
|
||||
return htmlspecialchars( $data, ENT_QUOTES );
|
||||
} else if( is_integer( $data ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user