<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblReporteRepository;

final class TblReporteService
{
    private TblReporteRepository $TblReporteRepository;

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

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

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

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

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

        return $this->TblReporteRepository->create($TblReporte);
    }

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

        return $this->TblReporteRepository->update($TblReporte, $data);
    }

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