<?php

namespace Modules\DemandeAchat\Rules;

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

class CreationDemandeAchat
{
    /** @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 creation(): bool
    {
        if (!$this->droits['DA_CreatModif']) {
            return false;
        }

        return true;
    }


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

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

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