GoogleDistanceServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Pnlinh\GoogleDistance\Providers;
4
5
use Illuminate\Contracts\Container\Container;
6
use Illuminate\Foundation\AliasLoader;
7
use Illuminate\Support\ServiceProvider;
8
use Pnlinh\GoogleDistance\GoogleDistance;
9
10
class GoogleDistanceServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Perform post-registration booting of services.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        if ($this->app->runningInConsole()) {
20
            $this->publishes([
21
                __DIR__.'/../config/google-distance.php' => config_path('google-distance.php'),
22
            ], 'google-distance');
23
        }
24
    }
25
26
    /**
27
     * Register any application services.
28
     *
29
     * @return void
30
     */
31
    public function register()
32
    {
33
        $this->app->singleton('google-distance', function (Container $app) {
34
            return new GoogleDistance($app['config']['google-distance.api_key'], $app['config']['google-distance.units']);
35
        });
36
37
        $this->app->booting(function () {
38
            $loader = AliasLoader::getInstance();
39
            $loader->alias('GoogleDistance', \Pnlinh\GoogleDistance\Facades\GoogleDistance::class);
40
        });
41
    }
42
}
43