<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblModuloRepository;

final class TblModuloService
{
    private TblModuloRepository $TblModuloRepository;

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

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

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

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

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

        return $this->TblModuloRepository->create($TblModulo);
    }

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

        return $this->TblModuloRepository->update($TblModulo, $data);
    }

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