<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblCursoRepository;

final class TblCursoService
{
    private TblCursoRepository $TblCursoRepository;

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

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

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

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

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

        return $this->TblCursoRepository->create($TblCurso);
    }

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

        return $this->TblCursoRepository->update($TblCurso, $data);
    }

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