<?php
namespace Modules\API\APIInterne\Magic\Rules;

use Psr\Http\Message\ServerRequestInterface;

class Import
{
    /** @var ServerRequestInterface $request */
    protected ServerRequestInterface $request;
    
    /** @var \PDO $pdo */
    protected \PDO $pdo;

    /** @var array<mixed> $documentAuthorize */
    protected array $documentAuthorize;
    
    /**
     * __construct
     *
     * @param  ServerRequestInterface $request
     * @param  \PDO $pdo
     * @return void
     */
    public function __construct(ServerRequestInterface  $request, \PDO $pdo)
    {
        $this->pdo = $pdo;
        $this->request = $request;

        $this->documentAuthorize = [
            'ARTICLES',
            'BR_RECEP',
            'CA_ENTET',
            'CENTRANA',
            'CENTRE',
            'CODECOMP',
            'CODGEST',
            'DA_ENTET',
            'DEVISES',
            'DIRECTIO',
            'DOC_ATT',
            'DS',
            'FABRICAN',
            'FAC_ENT',
            'FAC_REG',
            'FAMILLE',
            'FOURNINC',
            'FOURNISS',
            'GAMMES',
            'HASTUTIL',
            'NATANA',
            'RECEPDEST',
            'REMGAMM',
            'SBE_ENTE',
            'SBS_ENTE',
            'SECTIMPU',
            'SIGN_CROISE',
            'SI_UO',
            'SOCIETE',
            'SSCPTANA',
            'SSFAMILL',
            'TABLE_CS',
            'UO',
        ];
    }
    
    /**
     * exec
     *
     * @return bool
     */
    public function exec()
    {
        return (in_array(strtoupper($this->request->getAttribute('document')), $this->documentAuthorize));
    }


    /**
     * @return bool
     */
    public function statut(): bool
    {
        return true;
    }
}
