<?php
    namespace Model;
    use Entity\Quote;
    use Gateway\QuoteGateway;
    use Gateway\Gateway;
    use Enum\TypeSourceEnum;

    class SearchModel extends Model
    {

        public function searchQuote(?string $type,?string $search,array $filtre): array{
            
            $res = $this->gateway->search($type,$search,$filtre);
            $tabQ=[];

            foreach($res as $q ){
                $q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
                $tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
            }
            return $tabQ;
        }
    }
?>
