<?php

namespace App\Providers;

use App\Services\BrowserJobsInstances;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;

class BrowserJobsServiceProvider extends ServiceProvider
{

    private BrowserJobsInstances $service;

    public function __construct(Application $app)
    {
        parent::__construct($app);
        $this->service = new BrowserJobsInstances();
    }

    /**
     * Register services.
     */
    public function register(): void
    {
        $this->app->instance(BrowserJobsInstances::class, $this->service);
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        $this->app->terminating(function (BrowserJobsInstances $instances) {
            $instances->terminateAll();
        });
    }
}
