kawax/laravel-google-sheets

View on GitHub
lib/google/Providers/GoogleServiceProvider.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Revolution\Google\Client\Providers;

use Illuminate\Support\ServiceProvider;
use Revolution\Google\Client\GoogleSheetClient;

class GoogleServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     */
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__.'/../../../config/google.php', 'google');

        $this->app->singleton(GoogleSheetClient::class, fn ($app) => new GoogleSheetClient($app['config']['google']));

        $this->app->alias(GoogleSheetClient::class, 'google-client');
    }

    /**
     * Boot the service provider.
     */
    public function boot(): void
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__.'/../../../config/google.php' => config_path('google.php'),
            ], 'google-config');
        }
    }
}