Completed
Push — master ( a40fc9...4580d0 )
by ARCANEDEV
03:02
created

SettingsServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4286
c 2
b 0
f 0
ccs 5
cts 5
cp 1
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\Settings;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
use Illuminate\Foundation\Application;
5
6
/**
7
 * Class     SettingsServiceProvider
8
 *
9
 * @package  Arcanedev\Settings
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class SettingsServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Vendor name.
20
     *
21
     * @var string
22
     */
23
    protected $vendor  = 'arcanedev';
24
25
    /**
26
     * Package name.
27
     *
28
     * @var string
29
     */
30
    protected $package = 'settings';
31
32
    /* ------------------------------------------------------------------------------------------------
33
     |  Getters & Setters
34
     | ------------------------------------------------------------------------------------------------
35
     */
36
    /**
37
     * Get the base path of the package.
38
     *
39
     * @return string
40
     */
41 192
    public function getBasePath()
42
    {
43 192
        return dirname(__DIR__);
44
    }
45
46
    /* ------------------------------------------------------------------------------------------------
47
     |  Main Functions
48
     | ------------------------------------------------------------------------------------------------
49
     */
50
    /**
51
     * Register the service provider.
52
     */
53 192
    public function register()
54
    {
55 192
        $this->registerConfig();
56
57
        $this->singleton('arcanedev.settings.manager', function(Application $app) {
58 12
            return new SettingsManager($app);
59 192
        });
60
61 192
        $this->bind('arcanedev.settings.store', function(Application $app) {
62 3
            return $app->make('arcanedev.settings.manager')->driver();
63 192
        });
64
65 192
        $this->bind(
66 192
            \Arcanedev\Settings\Contracts\Store::class,
67
            'arcanedev.settings.store'
68 192
        );
69 192
    }
70
71
    /**
72
     * Boot the service provider.
73
     */
74 192
    public function boot()
75
    {
76 192
        parent::boot();
77
78 192
        $this->publishes([
79 192
            $this->getConfigFile() => config_path('settings.php')
80 192
        ], 'config');
81
82 192
        $this->publishes([
83 192
            $this->getBasePath() . '/database/migrations/' => database_path('migrations')
84 192
        ], 'migrations');
85 192
    }
86
87
    /**
88
     * Get the services provided by the provider.
89
     *
90
     * @return array
91
     */
92 3
    public function provides()
93
    {
94
        return [
95 3
            'arcanedev.settings.manager',
96 3
            'arcanedev.settings.store',
97 3
            \Arcanedev\Settings\Contracts\Store::class,
98 3
        ];
99
    }
100
}
101