<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblSegmentoCursoRepository;

final class TblSegmentoCursoService
{
    private TblSegmentoCursoRepository $TblSegmentoCursoRepository;

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

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

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

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

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

        return $this->TblSegmentoCursoRepository->create($TblSegmentoCurso);
    }

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

        return $this->TblSegmentoCursoRepository->update($TblSegmentoCurso, $data);
    }

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