LaravelNairaExchangeRatesServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Infinitypaul\LaravelNairaExchangeRates;
4
5
use Illuminate\Support\ServiceProvider;
6
use Infinitypaul\NairaExchangeRates\NairaExchangeRates as NExchangeRate;
7
8
class LaravelNairaExchangeRatesServiceProvider extends ServiceProvider
9
{
10
    /*
11
    * Indicates if loading of the provider is deferred.
12
    *
13
    * @var bool
14
    */
15
    protected $defer = true;
16
17
    /**
18
     * Bootstrap the application services.
19
     */
20
    public function boot()
21
    {
22
        if ($this->app->runningInConsole()) {
23
            $this->publishes([
24
                __DIR__.'/../config/nairaExchangeRate.php' => config_path('naira-exchange-rates.php'),
25
            ], 'config');
26
        }
27
    }
28
29
    /**
30
     * Register the application services.
31
     */
32
    public function register()
33
    {
34
        // Automatically apply the package configuration
35
        $this->mergeConfigFrom(__DIR__.'/../config/nairaExchangeRate.php', 'naira-exchange-rates');
36
37
        $this->app->bind('laravel-naira-exchange-rates', function () {
38
            return new NExchangeRate(config('naira-exchange-rates.accessToken'));
39
        });
40
    }
41
42
    /**
43
     * Get the services provided by the provider.
44
     * @return array
45
     */
46
    public function provides()
47
    {
48
        return ['laravel-naira-exchange-rates'];
49
    }
50
}
51