<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblPaisRepository;

final class TblPaisService
{
    private TblPaisRepository $TblPaisRepository;

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

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

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

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

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

        return $this->TblPaisRepository->create($TblPais);
    }

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

        return $this->TblPaisRepository->update($TblPais, $data);
    }

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