MenusServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 99
wmc 5
lcom 2
cbo 2
ccs 24
cts 24
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePath() 0 4 1
A register() 0 6 1
A boot() 0 8 1
A provides() 0 7 1
A registerMenuManagerService() 0 11 1
1
<?php namespace Arcanedev\Menus;
2
3
use Arcanedev\Support\PackageServiceProvider;
4
5
/**
6
 * Class     MenusServiceProvider
7
 *
8
 * @package  Arcanedev\Menus
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class MenusServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Vendor name.
19
     *
20
     * @var string
21
     */
22
    protected $vendor  = 'arcanedev';
23
24
    /**
25
     * Package name.
26
     *
27
     * @var string
28
     */
29
    protected $package = 'menus';
30
31
    /**
32
     * Indicates if loading of the provider is deferred.
33
     *
34
     * @var bool
35
     */
36
    protected $defer   = true;
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Getters & Setters
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Get the base path of the package.
44
     *
45
     * @return string
46
     */
47 240
    public function getBasePath()
48
    {
49 240
        return dirname(__DIR__);
50
    }
51
52
    /* ------------------------------------------------------------------------------------------------
53
     |  Main Functions
54
     | ------------------------------------------------------------------------------------------------
55
     */
56
    /**
57
     * Register the service provider.
58
     */
59 240
    public function register()
60
    {
61 240
        $this->registerConfig();
62
63 240
        $this->registerMenuManagerService();
64 240
    }
65
66
    /**
67
     * Boot the service provider.
68
     */
69 240
    public function boot()
70
    {
71 240
        parent::boot();
72
73 240
        $this->publishes([
74 240
            $this->getConfigFile() => config_path("{$this->package}.php"),
75 240
        ], 'config');
76 240
    }
77
78
    /**
79
     * Get the services provided by the provider.
80
     *
81
     * @return array
82
     */
83 16
    public function provides()
84
    {
85
        return [
86 16
            'arcanedev.menus.manager',
87 12
            \Arcanedev\Menus\Contracts\MenusManager::class,
88 12
        ];
89
    }
90
91
    /* ------------------------------------------------------------------------------------------------
92
     |  Services Functions
93
     | ------------------------------------------------------------------------------------------------
94
     */
95
    /**
96
     * Register the MenusManager service.
97
     */
98
    private function registerMenuManagerService()
99
    {
100 240
        $this->singleton('arcanedev.menus.manager', function () {
101 8
            return new MenusManager;
102 240
        });
103
104 240
        $this->app->bind(
105 240
            \Arcanedev\Menus\Contracts\MenusManager::class,
106 60
            \Arcanedev\Menus\MenusManager::class
107 180
        );
108 240
    }
109
}
110