ExpendableServiceProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 36
c 2
b 0
f 0
dl 0
loc 97
ccs 35
cts 35
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A alias() 0 6 1
A registerCommands() 0 10 3
A register() 0 19 1
A provides() 0 7 1
A boot() 0 23 1
1
<?php
2
3
namespace Distilleries\Expendable;
4
5
use Distilleries\Expendable\Layouts\LayoutManager;
6
use Distilleries\Expendable\Models\User;
7
use Distilleries\Expendable\States\StateDisplayer;
8
use Illuminate\Support\ServiceProvider;
9
use Illuminate\Foundation\AliasLoader;
10
11
class ExpendableServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Indicates if loading of the provider is deferred.
15
     *
16
     * @var bool
17
     */
18
    protected $defer = true;
19
20
    /**
21
     * Bootstrap the application events.
22
     *
23
     * @return void
24
     */
25 288
    public function boot()
26
    {
27
28 288
        $this->loadViewsFrom(__DIR__.'/../../views', 'expendable');
29 288
        $this->loadTranslationsFrom(__DIR__.'/../../lang', 'expendable');
30 288
        $this->loadMigrationsFrom(__DIR__.'/../../database/migrations/');
31
32
33 288
        $this->publishes([
34 288
            __DIR__.'/../../config/config.php'    => config_path('expendable.php'),
35 288
            __DIR__.'/../../database/seeds/'      => base_path('/database/seeds'),
36
        ]);
37
38
39 288
        $this->publishes([
40 288
            __DIR__.'/../../views' => base_path('resources/views/vendor/expendable'),
41 288
        ], 'views');
42 288
        $this->mergeConfigFrom(
43 288
            __DIR__.'/../../config/config.php', 'expendable'
44
        );
45
46 288
        $autoLoaderListener = new \Distilleries\Expendable\Register\ListenerAutoLoader(config('expendable.listener'));
47 288
        $autoLoaderListener->load();
48
49
    }
50
51
    /**
52
     * Register the service provider.
53
     *
54
     * @return void
55
     */
56 288
    public function register()
57
    {
58
        $this->app->singleton('Distilleries\Expendable\Contracts\LockableContract', function($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

58
        $this->app->singleton('Distilleries\Expendable\Contracts\LockableContract', function(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
        {
60 4
            return new User;
61 288
        });
62
63
        $this->app->singleton('Distilleries\Expendable\Contracts\StateDisplayerContract', function($app)
64
        {
65 152
            return new StateDisplayer($app['view'], $app['config']->get('expendable'));
66 288
        });
67
68
        $this->app->singleton('Distilleries\Expendable\Contracts\LayoutManagerContract', function($app)
69
        {
70 150
            return new LayoutManager($app['config']->get('expendable'), $app['view'], $app['files'], app('Distilleries\Expendable\Contracts\StateDisplayerContract'));
71 288
        });
72
73 288
        $this->alias();
74 288
        $this->registerCommands();
75
    }
76
77 288
    protected function registerCommands()
78
    {
79 288
        $file  = app('files');
80 288
        $files = $file->allFiles(__DIR__.'/Console/');
81
82 288
        foreach ($files as $file)
83
        {
84 288
            if (strpos($file->getPathName(), 'Lib') === false)
85
            {
86 288
                $this->commands('Distilleries\Expendable\Console\\'.preg_replace('/\.php/i', '', $file->getFilename()));
87
            }
88
        }
89
    }
90
91 8
    public function provides()
92
    {
93
        return [
94 8
            'Distilleries\Expendable\Contracts\StateDisplayerContract',
95
            'Distilleries\Expendable\Contracts\LayoutManagerContract',
96
            'Distilleries\Expendable\Contracts\ImportContract',
97
            'Distilleries\Expendable\Contracts\ExportContract',
98
        ];
99
    }
100
101
102 288
    public function alias()
103
    {
104
105 288
        AliasLoader::getInstance()->alias(
106 288
            'Excel',
107 288
            'Maatwebsite\Excel\Facades\Excel'
108
        );
109
    }
110
}