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

StoreManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 52
rs 10
c 0
b 0
f 0
ccs 13
cts 13
cp 1
wmc 4
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultDriver() 0 4 1
A loadStores() 0 14 2
A config() 0 4 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