<?php

namespace App\Services\Platforms;

use App\Contracts\PlatformAdapter;
use App\Exceptions\PlatformNotImplementedException;
use Illuminate\Contracts\Container\Container;

class PlatformAdapterFactory
{
    public function __construct(private Container $container) {}

    public function forPlatform(string $platform): PlatformAdapter
    {
        $class = config("creative.platform_adapters.{$platform}");

        if (! $class) {
            throw new PlatformNotImplementedException("No adapter is configured for platform [{$platform}].");
        }

        return $this->container->make($class);
    }
}
