Completed
Push — master ( 5c97e7...28953f )
by Dan Michael O.
02:14
created

GoogleBooksServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 16 1
A provides() 0 4 1
1
<?php
2
3
namespace Scriptotek\GoogleBooks;
4
5
use Illuminate\Foundation\Application;
6
use Illuminate\Support\ServiceProvider;
7
8
/**
9
 * Laravel 5 service provider
10
 */
11
class GoogleBooksServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application events.
15
     *
16
     * @return void
17
     */
18
    public function boot()
19
    {
20
        $this->publishes([
21
            __DIR__ . '/../config/config.php' => config_path('googlebooks.php')
22
        ]);
23
    }
24
25
    /**
26
     * Register the service provider.
27
     *
28
     * @return void
29
     */
30
    public function register()
31
    {
32
        $app = $this->app;
33
        $this->mergeConfigFrom(
34
            __DIR__.'/../../config/config.php',
35
            'googlebooks'
36
        );
37
        $this->app->singleton('googlebooks', function ($app) {
38
            $options = [];
39
            $options['key'] = $app['config']->get('googlebooks.key');
40
41
            return new GoogleBooks($options);
42
        });
43
44
        $app->alias('googlebooks', GoogleBooks::class);
45
    }
46
47
    /**
48
     * Get the services provided by the provider.
49
     *
50
     * @return array
51
     */
52
    public function provides()
53
    {
54
        return ['googlebooks'];
55
    }
56
}
57