27 lines
489 B
PHP
27 lines
489 B
PHP
<?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;
|
|
|
|
}
|
|
} |