Completed
Push — master ( 419c88...940d42 )
by Nicolas
03:31
created

ModulesServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
dl 0
loc 61
ccs 14
cts 20
cp 0.7
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A boot() 0 3 1
A registerModules() 0 4 1
A registerNamespaces() 0 9 1
registerServices() 0 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
     * Booting the package.
14
     */
15
    public function boot()
16
    {
17
    }
18
19
    /**
20
     * Register all modules.
21
     */
22
    public function register()
23
    {
24
    }
25
26
    /**
27
     * Register all modules.
28
     */
29 190
    protected function registerModules()
30
    {
31 190
        $this->app->register(BootstrapServiceProvider::class);
32 190
    }
33
34
    /**
35
     * Register package's namespaces.
36
     */
37 190
    protected function registerNamespaces()
38
    {
39 190
        $configPath = __DIR__ . '/../config/config.php';
40
41 190
        $this->mergeConfigFrom($configPath, 'modules');
42 190
        $this->publishes([
43 190
            $configPath => config_path('modules.php'),
44 190
        ], 'config');
45 190
    }
46
47
    /**
48
     * Register the service provider.
49
     */
50
    abstract protected function registerServices();
51
52
    /**
53
     * Get the services provided by the provider.
54
     *
55
     * @return array
56
     */
57
    public function provides()
58
    {
59
        return [Contracts\RepositoryInterface::class, 'modules'];
60
    }
61
62
    /**
63
     * Register providers.
64
     */
65 190
    protected function registerProviders()
66
    {
67 190
        $this->app->register(ConsoleServiceProvider::class);
68 190
        $this->app->register(ContractsServiceProvider::class);
69 190
    }
70
}
71