<?php

declare(strict_types=1);

namespace App\Service;

use App\Repository\MaestroRepository;

final class MaestroService
{
    private MaestroRepository $MaestroRepository;

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

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

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

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

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

        return $this->MaestroRepository->create($Maestro);
    }

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

        return $this->MaestroRepository->update($Maestro, $data);
    }

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