diff --git a/src/Logsnag.php b/src/Logsnag.php index 5e2bff2..5544d50 100644 --- a/src/Logsnag.php +++ b/src/Logsnag.php @@ -20,10 +20,12 @@ class Logsnag /** * Constructs a new Logsnag. + * + * @param LogsnagClient $client */ - public function __construct() + public function __construct(LogsnagClient $client) { - $this->client = app(LogsnagClient::class); + $this->client = $client; } /** diff --git a/src/LogsnagServiceProvider.php b/src/LogsnagServiceProvider.php index f369017..0c5c15d 100644 --- a/src/LogsnagServiceProvider.php +++ b/src/LogsnagServiceProvider.php @@ -31,13 +31,12 @@ public function configurePackage(Package $package): void */ protected function registerContainerBindings(): void { - // Bind the Logsnag client. - $this->app->instance(LogsnagClient::class, new LogsnagClient( - token: config('logsnag.token', ''), - )); + // Create client. + $client = new LogsnagClient(config('logsnag.token', '')); - // Bind the Logsnag. - $this->app->instance(Logsnag::class, new Logsnag()); + // Bind to container. + $this->app->instance(Logsnag::class, new Logsnag($client)); + $this->app->instance(LogsnagClient::class, $client); } }