Completed
Pull Request — master (#3)
by ARCANEDEV
09:28 queued 32s
created

SettingsServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 93
ccs 22
cts 22
cp 1
rs 10
wmc 5
lcom 1
cbo 3

5 Methods

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