MapperServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A register() 0 12 1
A provides() 0 4 1
1
<?php
2
3
namespace Cornford\Googlmapper;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class MapperServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Indicates if loading of the provider is deferred.
11
     *
12
     * @var bool
13
     */
14
    protected $defer = false;
15
16
    /**
17
     * Bootstrap the application events.
18
     *
19
     * @return void
20
     */
21
    public function boot()
22
    {
23
        $this->loadViewsFrom(base_path('resources/views/cornford/googlmapper'), 'googlmapper');
24
25
        $this->publishes(
26
            [
27
                __DIR__ . '/../config/config.php' => config_path('googlmapper.php'),
28
                __DIR__ . '/../resources/views' => base_path('resources/views/cornford/googlmapper')
29
            ],
30
            'googlmapper'
31
        );
32
33
        $this->app->alias(Mapper::class, 'mapper');
34
    }
35
36
    /**
37
     * Register the service provider.
38
     *
39
     * @return void
40
     */
41
    public function register()
42
    {
43
        $configPath = __DIR__ . '/../config/config.php';
44
        $this->mergeConfigFrom($configPath, 'googlmapper');
45
46
        $this->app->singleton(
47
            Mapper::class,
48
            function ($app) {
49
                return new Mapper($app->view, $app['config']->get('googlmapper'));
50
            }
51
        );
52
    }
53
54
    /**
55
     * Get the services provided by the provider.
56
     *
57
     * @return array
58
     */
59
    public function provides()
60
    {
61
        return ['mapper', Mapper::class];
62
    }
63
}
64