public static function secureData($data, string $type, bool $htmlentities)
    {
        $currentClass = get_called_class();
        
        if (is_array($data)) {
            foreach ($data as $key => $val) {
                unset($data[$key]);

                $key = $currentClass::secureData($key, gettype($key), true);
                $val = $currentClass::secureData($val, $type, $htmlentities);

                $data[$key] = $val;
            }

            return $data;
        }

        try {
            return $currentClass::secureKnownType($data, $type);
        } catch (Exception $ex) {
            if ($ex->getCode() !== self::ERR_SECURE_KNOWN_TYPE_FILTER_NOT_MANAGED) {
                throw new Exception($ex->getMessage(), $ex->getCode());
            }
            //Else : Use securise like if it's a text type
        }

        return $currentClass::secureUnknownType($data, $type, $htmlentities);
    }
public static function secureData($data, string $type, bool $htmlentities)
    {
        $currentClass = get_called_class();
        
        if (is_array($data)) {
            foreach ($data as $key => $val) {
                unset($data[$key]);

                $key = $currentClass::secureData($key, gettype($key), true);
                $val = $currentClass::secureData($val, $type, $htmlentities);

                $data[$key] = $val;
            }

            return $data;
        }

        try {
            return $currentClass::secureKnownType($data, $type);
        } catch (Exception $ex) {
            if ($ex->getCode() !== self::ERR_SECURE_KNOWN_TYPE_FILTER_NOT_MANAGED) {
                throw new Exception($ex->getMessage(), $ex->getCode());
            }
            //Else : Use securise like if it's a text type
        }

        return $currentClass::secureUnknownType($data, $type, $htmlentities);
    }
public static function secureData ( $ data , string $ type , bool $ htmlentities ) { $ currentClass = get_called_class ( ) ; if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ val ) { unset ( $ data [ $ key ] ) ; $ key = $ currentClass :: secureData ( $ key , gettype ( $ key ) , true ) ; $ val = $ currentClass :: secureData ( $ val , $ type , $ htmlentities ) ; $ data [ $ key ] = $ val ; } return $ data ; } try { return $ currentClass :: secureKnownType ( $ data , $ type ) ; } catch ( Exception $ ex ) { if ( $ ex -> getCode ( ) !== self :: ERR_SECURE_KNOWN_TYPE_FILTER_NOT_MANAGED ) { throw new Exception ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) ) ; } //Else : Use securise like if it's a text type } return $ currentClass :: secureUnknownType ( $ data , $ type , $ htmlentities ) ; }
Securise a variable

@param mixed $data The variable to securise
@param string $type The type of datas
@param boolean $htmlentities If use htmlentities function
to a better security

@return mixed

@throws \Exception If an error with a type of data
Securise a variable