Completed
Push — master ( 2ca05d...6b4c2a )
by Nicolas
03:24
created

ModulesServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 76%

Importance

Changes 0
Metric Value
dl 0
loc 75
ccs 19
cts 25
cp 0.76
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3

7 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 3 1
A register() 0 3 1
A registerModules() 0 4 1
A registerNamespaces() 0 9 1
A registerServices() 0 8 1
A provides() 0 4 1
A registerProviders() 0 5 1
1
<?php
2
3
namespace Nwidart\Modules;
4
5
use Illuminate\Support\ServiceProvider;
6
use Nwidart\Modules\Providers\BootstrapServiceProvider;
7
use Nwidart\Modules\Providers\ConsoleServiceProvider;
8
use Nwidart\Modules\Providers\ContractsServiceProvider;
9
10
abstract class ModulesServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Indicates if loading of the provider is deferred.
14
     *
15
     * @var bool
16
     */
17
    protected $defer = false;
18
19
    /**
20
     * Booting the package.
21
     */
22
    public function boot()
23
    {
24
    }
25
26
    /**
27
     * Register all modules.
28
     */
29
    public function register()
30
    {
31
    }
32
33
    /**
34
     * Register all modules.
35
     */
36 111
    protected function registerModules()
37
    {
38 111
        $this->app->register(BootstrapServiceProvider::class);
39 111
    }
40
41
    /**
42
     * Register package's namespaces.
43
     */
44 111
    protected function registerNamespaces()
45
    {
46 111
        $configPath = __DIR__ . '/../config/config.php';
47
48 111
        $this->mergeConfigFrom($configPath, 'modules');
49 111
        $this->publishes([
50 111
            $configPath => config_path('modules.php'),
51 111
        ], 'config');
52 111
    }
53
54
    /**
55
     * Register the service provider.
56
     */
57
    protected function registerServices()
58
    {
59 111
        $this->app->singleton('modules', function ($app) {
60 111
            $path = $app['config']->get('modules.paths.modules');
61
62 111
            return new Repository($app, $path);
63 111
        });
64 111
    }
65
66
    /**
67
     * Get the services provided by the provider.
68
     *
69
     * @return array
70
     */
71
    public function provides()
72
    {
73
        return ['modules'];
74
    }
75
76
    /**
77
     * Register providers.
78
     */
79 111
    protected function registerProviders()
80
    {
81 111
        $this->app->register(ConsoleServiceProvider::class);
82 111
        $this->app->register(ContractsServiceProvider::class);
83 111
    }
84
}
85