<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblSupervisorRepository;

final class TblSupervisorService
{
    private TblSupervisorRepository $TblSupervisorRepository;

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

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

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

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

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

        return $this->TblSupervisorRepository->create($TblSupervisor);
    }

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

        return $this->TblSupervisorRepository->update($TblSupervisor, $data);
    }

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