<?php

namespace Modules\GlobalApplication\Service;

use Modules\GlobalApplication\Repository\Incidents;

class IncidentService
{
    /**
     *
     * @var \PDO pdo
     */
    private \PDO $pdo;

    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }

    /**
     * createIncident
     *
     * @param  string $module
     * @param  array<mixed> $post
     */
    public function createIncident(
        string $module,
        array $post
    ): void {
        switch ($module) {
            case 'Commande':
                (new Incidents($this->pdo))->createIncident(
                    $post['NO_CDE'],
                    $post['PO_CDE'],
                    $post['DESCRIPT'],
                    $post['CONTMEMO'],
                    $post['CODE'],
                    $post['NO_BR'] ?? '',
                    $post['PO_BR'] ?? '',
                    $post['QTE_REFU'] ?? ''
                );
                break;

            default:
                (new Incidents($this->pdo))->creationIncident($post);
                break;
        }
    }
}
