<?php

namespace Modules\ProjetAchat\Service;

use Helpers\Trad\ITrad;
use Modules\ProjetAchat\Repository\ElementConcerned;
use Helpers\Trad\Trad;
use Skeleton\Router;

class ElementsConcernedService
{
 
    private \PDO $pdo;
    private ITrad $trad;

    public function __construct(\PDO $pdo, ITrad $trad)
    {
        $this->pdo = $pdo;
        $this->trad = $trad;
    }
    
    /**
     * @return array<mixed>
    */
    public function generateArrayElementConcerned() : ?array
    {
        $elementConcernedRepo = new ElementConcerned($this->pdo);
        $elementConcerned = $elementConcernedRepo->getListElementsConcerned();

        $array = [];
        foreach ($elementConcerned as $val) {
            $array[$val['TYPE_ELEM']] = $this->trad->t($val['LIBELLE']);
        }
        
        return $array;
    }
}
