<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblRolPaisRepository;

final class TblRolPaisService
{
    private TblRolPaisRepository $TblRolPaisRepository;

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

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

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

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

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

        return $this->TblRolPaisRepository->create($TblRolPais);
    }

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

        return $this->TblRolPaisRepository->update($TblRolPais, $data);
    }

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