<?php
declare(strict_types=1);

namespace App\DataProvider\Mobyt;

use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use App\ApiResources\Mobyt\MobytUserStatus;
use App\Service\ApiResourceBuilder\Mobyt\MobytUserStatusBuilder;

/**
 * Custom provider pour les MobytUserStatus récupérés via l'api Mobyt
 * @package App\DataProvider\Utils
 */
final class MobytUserStatusDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{
    public function __construct(
        private MobytUserStatusBuilder $mobytUserStatusCreator,
    )
    {}

    public function supports(string $resourceClass, string $operationName = null, array $context = []): bool
    {
        return MobytUserStatus::class === $resourceClass;
    }

    public function getItem(string $resourceClass, $id, string $operationName = null, array $context = []): ?MobytUserStatus
    {
        return $this->mobytUserStatusCreator->getUserStatus($id);
    }
}
