<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblTipoNoticiaGenfarRepository;

final class TblTipoNoticiaGenfarService
{
    private TblTipoNoticiaGenfarRepository $TblTipoNoticiaGenfarRepository;

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

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

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

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

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

        return $this->TblTipoNoticiaGenfarRepository->create($TblTipoNoticiaGenfar);
    }

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

        return $this->TblTipoNoticiaGenfarRepository->update($TblTipoNoticiaGenfar, $data);
    }

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