<?php

namespace App\Providers;

use App\FiveM\Adapters\ESXAdapter;
use App\FiveM\Adapters\QBCoreAdapter;
use App\FiveM\Adapters\QboxAdapter;
use App\FiveM\Contracts\FrameworkAdapter;
use Illuminate\Support\ServiceProvider;
use RuntimeException;

class FiveMServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(FrameworkAdapter::class, function () {
            return match (config('fivem.framework')) {
                'qbcore' => new QBCoreAdapter,
                'qbox' => new QboxAdapter,
                'esx' => new ESXAdapter,
                default => throw new RuntimeException(
                    'Unknown fivem.framework config value: '.config('fivem.framework').'. Expected one of: qbcore, qbox, esx.'
                ),
            };
        });
    }
}
