<?php

namespace App\Providers;

use App\Services\PaymentGatewayManager;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;

class PaymentServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register()
    {
        $this->app->bind('paymentGateway', function ($app, $params) {
            if (!isset($params['provider'])) {
                throw new InvalidArgumentException('Payment provider not specified.');
            }

            /** @var PaymentGatewayManager $manager */
            $manager = $app->make(PaymentGatewayManager::class);

            return $manager->getGateway($params['provider']);
        });
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        //
    }
}
