MessengerLumenServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php namespace Distilleries\Messenger;
2
3
use Distilleries\Messenger\Helpers\Message;
4
use GuzzleHttp\Client;
5
use Illuminate\Support\ServiceProvider;
6
7
class MessengerLumenServiceProvider extends ServiceProvider {
8
9
10
    protected $package = 'messenger';
11
    protected $namespace = 'Distilleries\Messenger\Http\Controllers';
12
13
14
    public function boot()
15
    {
16
        $this->loadViewsFrom(__DIR__.'/../../views', $this->package);
17
        $this->loadTranslationsFrom(__DIR__.'/../../lang', $this->package);
18
        $this->map();
19
    }
20
21
    /**
22
     * Register the service provider.
23
     *
24
     * @return void
25
     */
26 View Code Duplication
    public function register()
27
    {
28
        $this->mergeConfigFrom(
29
            __DIR__.'/../../config/config.php',
30
            $this->package
31
        );
32
33
34
        $this->app['messenger'] = $this->app->share(function($app)
35
        {
36
            return new Message($app['config']->get('messenger'),new Client());
37
        });
38
39
        $this->alias();
40
    }
41
42
    /**
43
     * Get the services provided by the provider.
44
     *
45
     * @return string[]
46
     */
47
    public function provides()
48
    {
49
        return array('messenger');
50
    }
51
52
53
    public function alias() {
54
55
        $this->app->alias('Route','Illuminate\Support\Facades\Route');
56
        $this->app->alias('Log','Illuminate\Support\Facades\Log');
57
58
    }
59
60
    /**
61
     * Define the routes for the application.
62
     *
63
     * @return void
64
     */
65
    public function map()
66
    {
67
        $this->app->group(['namespace' => $this->namespace], function($app)
68
        {
69
            require __DIR__ . '/Http/routes_lumen.php';
70
        });
71
    }
72
}