<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblNoticiaGenfarRepository;

final class TblNoticiaGenfarService
{
    private TblNoticiaGenfarRepository $TblNoticiaGenfarRepository;

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

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

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

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

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

        return $this->TblNoticiaGenfarRepository->create($TblNoticiaGenfar);
    }

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

        return $this->TblNoticiaGenfarRepository->update($TblNoticiaGenfar, $data);
    }

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