<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TestimonioRepository;

final class TestimonioService
{
    private TestimonioRepository $TestimonioRepository;

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

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

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

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

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

        return $this->TestimonioRepository->create($Testimonio);
    }

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

        return $this->TestimonioRepository->update($Testimonio, $data);
    }

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