<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\TblRolPanelRepository;

final class TblRolPanelService
{
    private TblRolPanelRepository $TblRolPanelRepository;

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

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

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

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

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

        return $this->TblRolPanelRepository->create($TblRolPanel);
    }

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

        return $this->TblRolPanelRepository->update($TblRolPanel, $data);
    }

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