Completed
Push — master ( 7fd3c6...8bfe8f )
by ARCANEDEV
04:13
created

NotifyServiceProvider::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\Notify;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
5
/**
6
 * Class     NotifyServiceProvider
7
 *
8
 * @package  Arcanedev\Notify
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class NotifyServiceProvider extends ServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'notify';
24
25
    /**
26
     * Indicates if loading of the provider is deferred.
27
     *
28
     * @var bool
29
     */
30
    protected $defer = true;
31
32
    /* ------------------------------------------------------------------------------------------------
33
     |  Main Functions
34
     | ------------------------------------------------------------------------------------------------
35
     */
36
    /**
37
     * Register the service provider.
38
     */
39 45
    public function register()
40
    {
41 45
        parent::register();
42
43 45
        $this->registerConfig();
44
45 45
        $this->bindSession();
46 45
        $this->registerNotifyService();
47 45
    }
48
49
    /**
50
     * Boot the package.
51
     */
52 45
    public function boot()
53
    {
54 45
        parent::boot();
55
56 45
        $this->publishConfig();
57 45
    }
58
59
    /**
60
     * Get the services provided by the provider.
61
     *
62
     * @return array
63
     */
64 6
    public function provides()
65
    {
66
        return [
67 6
            Contracts\Notify::class,
68 2
        ];
69
    }
70
71
    /* ------------------------------------------------------------------------------------------------
72
     |  Services
73
     | ------------------------------------------------------------------------------------------------
74
     */
75
    /**
76
     * Bind the Session Class.
77
     */
78 45
    private function bindSession()
79
    {
80 45
        $this->bind(Contracts\SessionStore::class, Storage\Session::class);
81 45
    }
82
83
    /**
84
     * Register the Notify service.
85
     */
86
    private function registerNotifyService()
87
    {
88 45
        $this->singleton(Contracts\Notify::class, function ($app) {
89
            /**  @var \Illuminate\Config\Repository  $config  */
90 30
            $config = $app['config'];
91
92 30
            return new Notify(
93 30
                $app[Contracts\SessionStore::class],
94 30
                $config->get('notify.session.prefix', 'notifier.')
95 10
            );
96 45
        });
97 15
    }
98
}
99