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

use Psr\Http\Message\ServerRequestInterface;

class Export
{
     /** @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',
            'CCA',
            'CENTRANA',
            'CODECOMP',
            'CODGEST',
            'DA_ENTET',
            'DEVISES',
            'DIRECTIO',
            'DOC_ATT',
            'ENGAGE',
            'FABRICAN',
            'FAC_ENT',
            'FAMILLE',
            'FAR',
            'FOURNINC',
            'FOURNISS',
            'GAMMES',
            'HASTUTIL',
            'NATANA',
            'REMGAMM',
            'SBE_ENTE',
            'SBS_ENTE',
            'SECTIMPU',
            'SI_UO',
            'SMOUVEME',
            'SSCPTANA',
            'SSFAMILL',
            'TABLE_CS',
            'UO',
        ];
    }
        
    /**
     * exec
     *
     * @return bool
     */
    public function exec()
    {
        return (in_array(strtoupper($this->request->getAttribute('document')), $this->documentAuthorize));
    }
}
