<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblNoticiaGenfarPaisRepository;

final class TblNoticiaGenfarPaisService
{
    private TblNoticiaGenfarPaisRepository $TblNoticiaGenfarPaisRepository;

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

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

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

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

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

        return $this->TblNoticiaGenfarPaisRepository->create($TblNoticiaGenfarPais);
    }

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

        return $this->TblNoticiaGenfarPaisRepository->update($TblNoticiaGenfarPais, $data);
    }

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