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

    class SearchModel
    {
        private QuoteGateway $gateway;

        public function __construct(QuoteGateway $gate){
            $this->gateway = $gate;
        }

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

            foreach($res as $q ){
                $tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"]) ;
            }
            return $tabQ;
        }
    }
    
?>
