<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblTemaRepository;

final class TblTemaService
{
    private TblTemaRepository $TblTemaRepository;

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

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

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

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

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

        return $this->TblTemaRepository->create($TblTema);
    }

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

        return $this->TblTemaRepository->update($TblTema, $data);
    }

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