Completed
Pull Request — master (#8)
by ARCANEDEV
05:19
created

FoundationServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 100
ccs 29
cts 29
cp 1
rs 10
wmc 6
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePath() 0 4 1
A boot() 0 13 1
A registerFoundationService() 0 4 1
A provides() 0 6 1
A registerModuleProviders() 0 6 1
A register() 0 14 1
1
<?php namespace Arcanesoft\Foundation;
2
3
use Arcanesoft\Core\Bases\PackageServiceProvider;
4
5
/**
6
 * Class     FoundationServiceProvider
7
 *
8
 * @package  Arcanesoft\Foundation
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class FoundationServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package = 'foundation';
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Getters & Setters
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * Get the base path of the package.
30
     *
31
     * @return string
32
     */
33 21
    public function getBasePath()
34
    {
35 21
        return dirname(__DIR__);
36
    }
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Main Functions
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Register the service provider.
44
     */
45 21
    public function register()
46
    {
47 21
        parent::register();
48
49 21
        $this->registerConfig();
50 21
        $this->registerSidebarItems();
51 21
        $this->registerProviders([
52 21
            Providers\PackagesServiceProvider::class,
53
            Providers\AuthorizationServiceProvider::class,
54
        ]);
55 21
        $this->registerModuleProviders();
56 21
        $this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class);
57 21
        $this->registerFoundationService();
58 21
    }
59
60
    /**
61
     * Boot the service provider.
62
     */
63 21
    public function boot()
64
    {
65 21
        $this->registerProviders([
66 21
            Providers\RouteServiceProvider::class,
67
            Providers\ViewComposerServiceProvider::class,
68
        ]);
69
70
        // Publishes
71 21
        $this->publishConfig();
72 21
        $this->publishViews();
73 21
        $this->publishTranslations();
74 21
        $this->publishSidebarItems();
75 21
    }
76
77
    /**
78
     * Get the services provided by the provider.
79
     *
80
     * @return array
81
     */
82 3
    public function provides()
83
    {
84
        return [
85 3
            Contracts\Foundation::class,
86
        ];
87
    }
88
89
    /* ------------------------------------------------------------------------------------------------
90
     |  Services Functions
91
     | ------------------------------------------------------------------------------------------------
92
     */
93
    /**
94
     * Register Foundation service.
95
     */
96 21
    private function registerFoundationService()
97
    {
98 21
        $this->singleton(Contracts\Foundation::class, Foundation::class);
99 21
    }
100
101
    /**
102
     * Register ARCANESOFT's modules (providers).
103
     */
104 21
    private function registerModuleProviders()
105
    {
106 21
        $this->registerProviders(
107 21
            $this->config()->get('arcanesoft.foundation.modules.providers', [])
108
        );
109 21
    }
110
}
111