<?php

namespace Modules\Consultation\Rules;

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

class IndicateurConsultation
{
    /** @var ServerRequestInterface $request */
    protected ServerRequestInterface $request;

    /** @var \PDO $pdo */
    protected \PDO $pdo;

    /** @var string|mixed $currentUser */
    protected $currentUser;

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

    /**
     * @param ServerRequestInterface $request
     * @param \PDO $pdo
     */
    public function __construct(ServerRequestInterface $request, \PDO $pdo)
    {
        $this->request              = $request;
        $this->pdo                  = $pdo;
        $this->currentUser          = $_SESSION['Session_Login'];
        $this->droits               = [
            'HA_AO_CMV' => Roles::droitsUtilisateur($this->pdo, 'HA_AO_CMV'),
            'HA_AO_ADM' => Roles::droitsUtilisateur($this->pdo, 'HA_AO_ADM'),
            'HA_AO_LIS' => Roles::droitsUtilisateur($this->pdo, 'HA_AO_LIS'),
        ];
    }

    /**
     * @return bool
     */
    public function indicateur(): bool
    {
        if (!$this->droits['HA_AO_CMV'] && !$this->droits['HA_AO_ADM'] && !$this->droits['HA_AO_LIS']) {
            return false;
        }

        return true;
    }
}
