<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblTipoRepository;

final class TblTipoService
{
    private TblTipoRepository $TblTipoRepository;

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

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

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

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

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

        return $this->TblTipoRepository->create($TblTipo);
    }

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

        return $this->TblTipoRepository->update($TblTipo, $data);
    }

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