<?php
namespace Verification;

    class Verification
    {
        public static function verifChar(?string $text) : ?string{
            if($text==NULL){
                return NULL;
            }
            $charInterdi=['|','/','\\','%','$','=','<','>','(',')',';'];
            $chaineInterdi=["AND","OR","WHERE","FROM","SELECT","DROP","DELETE","TABLE","Users"];
            $textVerif="";

            foreach( str_split($text,1) as $char){
                if( !in_array($char,$charInterdi) ){
                    $textVerif=$textVerif.$char;
                }
            }

            $text=$textVerif;
            $textVerif="";
            $tabText=explode(" ",$text);
            for( $i=0 ; $i<count($tabText) ; $i++){
                if( !in_array( strtoupper($tabText[$i]) , $chaineInterdi )){
                    $textVerif=$textVerif.$tabText[$i];

                    if($i != count($tabText)-1){
                        $textVerif=$textVerif." ";
                    }
                }
            }
            return $textVerif;
        }

        public static function verifArrayChar(?array $tabText) : ?array{
            for( $i=0 ; $i<count($tabText) ; $i++){
                $tabText[$i]=$this->verifChar($tabText[$i]);
            }
            return $tabText;
        }

        public static function verifNotNull($val) :bool{
            return empty($var);
        }
        
    }

?>