Completed
Push — master ( 3cf617...93247c )
by Saurabh
08:56
created

SignereServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sausin\Signere;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Contracts\Events\Dispatcher;
8
9
class SignereServiceProvider extends ServiceProvider
10
{
11
    use EventMap;
12
13
    /**
14
     * Bootstrap the application services.
15
     *
16
     * @return void
17
     */
18 48
    public function boot()
19
    {
20
        // $this->registerEvents();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21 48
        $this->registerRoutes();
22 48
        $this->defineAssetPublishing();
23 48
    }
24
25
    /**
26
     * Register the Signere job events.
27
     *
28
     * @return void
29
     */
30
    protected function registerEvents()
31
    {
32
        $events = $this->app->make(Dispatcher::class);
33
34
        foreach ($this->events as $event => $listeners) {
35
            foreach ($listeners as $listener) {
36
                $events->listen($event, $listener);
37
            }
38
        }
39
    }
40
41
    /**
42
     * Register the Signere routes.
43
     *
44
     * @return void
45
     */
46 48
    protected function registerRoutes()
47
    {
48 48
        Route::group([
49 48
            'prefix' => 'signere',
50
            'namespace' => 'Sausin\Signere\Http\Controllers',
51
            'middleware' => 'web',
52 48
        ], function () {
53 48
            $this->loadRoutesFrom(__DIR__.'/../routes/api.php');
54 48
        });
55 48
    }
56
57
    /**
58
     * Define the asset publishing configuration.
59
     *
60
     * @return void
61
     */
62 48
    public function defineAssetPublishing()
63
    {
64 48
        $this->publishes([
65 48
            SIGNERE_PATH.'/public' => public_path('vendor/signere'),
66 48
        ], 'signere-assets');
67 48
    }
68
69
    /**
70
     * Register any application services.
71
     *
72
     * @return void
73
     */
74 48
    public function register()
75
    {
76 48
        if (! defined('SIGNERE_PATH')) {
77 1
            define('SIGNERE_PATH', realpath(__DIR__.'/../'));
78
        }
79
80 48
        $this->registerFacades();
81 48
        $this->configure();
82 48
        $this->offerPublishing();
83 48
    }
84
85
    protected function registerFacades()
86
    {
87 48
        $this->app->bind('signere-headers', function () {
88 1
            return new Headers(config());
89 48
        });
90 48
        $this->app->bind('signere-status', function ($app) {
91 1
            return new Status($app->make('GuzzleHttp\Client'), $app->make(Headers::class), config());
92 48
        });
93 48
        $this->app->bind('signere-events', function ($app) {
94 1
            return new Events($app->make('GuzzleHttp\Client'), $app->make(Headers::class));
95 48
        });
96 48
        $this->app->bind('signere-api-key', function ($app) {
97 1
            return new ApiKey($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $app->environment());
98 48
        });
99
100 48
        $this->app->alias('signere-headers', Facades\SignereHeaders::class);
101 48
        $this->app->alias('signere-status', Facades\SignereStatus::class);
102 48
        $this->app->alias('signere-events', Facades\SignereStatus::class);
103 48
        $this->app->alias('signere-api-key', Facades\SignereApiKey::class);
104 48
    }
105
106
    /**
107
     * Setup the configuration for Signere.
108
     *
109
     * @return void
110
     */
111 48
    protected function configure()
112
    {
113 48
        $this->mergeConfigFrom(
114 48
            __DIR__.'/../config/signere.php',
115 48
            'signere'
116
        );
117 48
    }
118
119
    /**
120
     * Setup the resource publishing groups for Signere.
121
     *
122
     * @return void
123
     */
124 48
    protected function offerPublishing()
125
    {
126 48
        if ($this->app->runningInConsole()) {
127 48
            $this->publishes([
128 48
                __DIR__.'/../config/signere.php' => config_path('signere.php'),
129 48
            ], 'signere-config');
130
        }
131 48
    }
132
}
133