Passed
Push — master ( c2d3c3...2d4925 )
by Innocent
06:21
created

MiscellaneousServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 20
c 3
b 0
f 0
dl 0
loc 48
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 17 2
A register() 0 12 1
A routeConfiguration() 0 5 1
1
<?php
2
3
namespace Faithgen\Miscellaneous;
4
5
use Faithgen\Miscellaneous\Models\Subscription;
6
use Faithgen\Miscellaneous\Observers\SubscriptionObserver;
7
use Faithgen\Miscellaneous\Services\ContactService;
8
use Faithgen\Miscellaneous\Services\SubscriptionService;
9
use FaithGen\SDK\Traits\ConfigTrait;
10
use Illuminate\Support\ServiceProvider;
11
12
class MiscellaneousServiceProvider extends ServiceProvider
13
{
14
    use ConfigTrait;
15
16
    /**
17
     * Bootstrap the application services.
18
     */
19
    public function boot()
20
    {
21
        $this->registerRoutes(__DIR__.'/../routes/miscellaneous.php', null);
22
23
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
24
25
        if ($this->app->runningInConsole()) {
26
            $this->publishes([
27
                __DIR__.'/../config/config.php' => config_path('miscellaneous.php'),
28
            ], 'misc-config');
29
30
            $this->publishes([
31
                __DIR__.'/../database/migrations/' => database_path('migrations'),
32
            ], 'miscellaneous-migrations');
33
        }
34
35
        Subscription::observe(SubscriptionObserver::class);
36
    }
37
38
    /**
39
     * Register the application services.
40
     */
41
    public function register()
42
    {
43
        // Automatically apply the package configuration
44
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'miscellaneous');
45
46
        // Register the main class to use with the facade
47
        $this->app->singleton('miscellaneous', function () {
48
            return new Miscellaneous;
49
        });
50
51
        $this->app->singleton(ContactService::class);
52
        $this->app->singleton(SubscriptionService::class);
53
    }
54
55
    public function routeConfiguration(): array
56
    {
57
        return [
58
            'prefix'     => config('miscellaneous.prefix'),
59
            'middleware' => config('miscellaneous.middlewares'),
60
        ];
61
    }
62
}
63