<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\SolicitudRepository;

final class SolicitudService
{
    private SolicitudRepository $SolicitudRepository;

    public function __construct(SolicitudRepository $SolicitudRepository)
    {
        $this->SolicitudRepository = $SolicitudRepository;
    }

    public function checkAndGet(int $SolicitudId): object
    {
        return $this->SolicitudRepository->checkAndGet($SolicitudId);
    }

    public function getAll(): array
    {
        return $this->SolicitudRepository->getAll();
    }

    public function getOne(int $SolicitudId): object
    {
        return $this->checkAndGet($SolicitudId);
    }

    public function create(array $input): object
    {
        $Solicitud = json_decode((string) json_encode($input), false);

        return $this->SolicitudRepository->create($Solicitud);
    }

    public function update(array $input, int $SolicitudId): object
    {
        $Solicitud = $this->checkAndGet($SolicitudId);
        $data = json_decode((string) json_encode($input), false);

        return $this->SolicitudRepository->update($Solicitud, $data);
    }

    public function delete(int $SolicitudId): void
    {
        $this->checkAndGet($SolicitudId);
        $this->SolicitudRepository->delete($SolicitudId);
    }
}
