<?php

namespace Modules\GlobalApplication\Outil;

use Entity\Model\DaEntet;
use Entity\Model\Paravrac;

class InitAxesImpDa extends AbsInitAxesImput
{
    
    /**
     *  @param array<mixed> $entete
     */
    public function __construct(\PDO $pdo, $entete = [])
    {
        parent::__construct($pdo, $entete);
    }

    /**
     * @return array{SI:array<string>,SCA:array<string>,CDC:array<string>}
     */
    protected function getPriorities() :array
    {
        $paravrac = new Paravrac($this->pdo);
        $INIT_IMP = $paravrac->getValue('INIT_IMPD', $this->entete['TYP_DOC']??'');
            
        if (!$INIT_IMP) {
            $INIT_IMP = $paravrac->getValue('INIT_IMPDA', '');
        }
        // <P1SI>;<P2SI>;<P3SI>|<P1SCA>;<P2SCA>;<P3SCA>|<P1CDC>;<P2CDC>;<P3CDC>
        $priorites = explode('|', $INIT_IMP);

        return [
            'SI' => explode(';', $priorites[0]),
            'SCA' => explode(';', $priorites[1]),
            'CDC' => explode(';', $priorites[2]),
        ];
    }

    protected function getEntityClass() :string
    {
        return DaEntet::class;
    }
}
