<?php

namespace Modules\DemandeAchat\Rules;

use Helpers\Outil\Roles;
use Psr\Http\Message\ServerRequestInterface;

class PopupChoixCreationDemandeAchat
{
    /** @var ServerRequestInterface $request */
    // @phpstan-ignore-next-line
    private ServerRequestInterface $request;

    /** @var \PDO $pdo */
    // @phpstan-ignore-next-line
    private \PDO $pdo;

    /** @var array<mixed> $droits */
    private array $droits;

    /**
     * @param ServerRequestInterface $request
     * @param \PDO $pdo
     */
    public function __construct(ServerRequestInterface $request, \PDO $pdo)
    {
        $this->request              = $request;
        $this->pdo                  = $pdo;
        $this->droits               = [
            'DA_CreatModif' => Roles::droitsUtilisateur($this->pdo, 'HA_DA_CRE')
        ];
    }

    /**
     * @return bool
     */
    public function choixCreation(): bool
    {
        if (!$this->droits['DA_CreatModif']) {
            return false;
        }

        return true;
    }
}
