Completed
Push — master ( 86fb23...6085dd )
by ARCANEDEV
25s
created

StoreManager::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Notify;
2
3
use Illuminate\Support\Manager;
4
5
/**
6
 * Class     StoreManager
7
 *
8
 * @package  Arcanedev\Notify
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class StoreManager extends Manager
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Methods
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Get the default driver name.
20
     *
21
     * @return string
22
     */
23 48
    public function getDefaultDriver()
24
    {
25 48
        return $this->app['config']->get('notify.default', 'session');
26
    }
27
28
    /**
29
     * Load the stores.
30
     *
31
     * @return void
32
     */
33 48
    public function loadStores(): void
34
    {
35 48
        $stores = $this->config()->get('notify.stores', []);
36
37 48
        foreach ($stores as $driver => $store) {
38
            $this->extend($driver, function () use ($store) {
39 48
                return $this->app->make($store['driver']);
40 48
            });
41
42 48
            $this->app->when($store['driver'])
43 48
                      ->needs('$options')
44 48
                      ->give($store['options'] ?? []);
45
        }
46 48
    }
47
48
    /* -----------------------------------------------------------------
49
     |  Other Methods
50
     | -----------------------------------------------------------------
51
     */
52
53
    /**
54
     * Get the config repository.
55
     *
56
     * @return \Illuminate\Contracts\Config\Repository
57
     */
58 48
    protected function config()
59
    {
60 48
        return $this->app['config'];
61
    }
62
}
63