<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblRolRepository;

final class TblRolService
{
    private TblRolRepository $TblRolRepository;

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

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

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

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

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

        return $this->TblRolRepository->create($TblRol);
    }

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

        return $this->TblRolRepository->update($TblRol, $data);
    }

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