<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblAdminRepository;

final class TblAdminService
{
    private TblAdminRepository $TblAdminRepository;

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

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

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

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

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

        return $this->TblAdminRepository->create($TblAdmin);
    }

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

        return $this->TblAdminRepository->update($TblAdmin, $data);
    }

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