<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblValorTipoRepository;

final class TblValorTipoService
{
    private TblValorTipoRepository $TblValorTipoRepository;

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

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

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

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

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

        return $this->TblValorTipoRepository->create($TblValorTipo);
    }

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

        return $this->TblValorTipoRepository->update($TblValorTipo, $data);
    }

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