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

SettingsManager::createArrayDriver()   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 2
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 2
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\Settings;
2
3
use Illuminate\Support\Manager;
4
5
/**
6
 * Class     SettingsManager
7
 *
8
 * @package  Arcanedev\Settings
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class SettingsManager extends Manager
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Get the default driver name.
19
     *
20
     * @return string
21
     */
22 9
    public function getDefaultDriver()
23
    {
24 9
        return $this->getConfig('settings.default', 'json');
25
    }
26
27
    /* ------------------------------------------------------------------------------------------------
28
     |  Driver Functions
29
     | ------------------------------------------------------------------------------------------------
30
     */
31
    /**
32
     * Create the Json driver store.
33
     *
34
     * @return string
35
     */
36 6
    public function createJsonDriver()
37
    {
38 6
        return new Stores\JsonStore(
39 6
            $this->app['files'],
40 6
            $this->getConfig('settings.stores.json.path')
41 6
        );
42
    }
43
44
    /**
45
     * Create the Database driver store.
46
     *
47
     * @return string
48
     */
49 3
    public function createDatabaseDriver()
50
    {
51 3
        $connection = $this->getConfig('settings.stores.database.connection');
52
53 3
        return new Stores\DatabaseStore(
54 3
            $this->app['db']->connection($connection),
55 3
            $this->getConfig('settings.stores.database.table')
56 3
        );
57
    }
58
59
    /**
60
     * Create the Memory driver store.
61
     *
62
     * @return string
63
     */
64 3
    public function createMemoryDriver()
65
    {
66 3
        return new Stores\MemoryStore;
67
    }
68
69
    /**
70
     * Create the Array driver store.
71
     *
72
     * @return string
73
     */
74 3
    public function createArrayDriver()
75
    {
76 3
        return new Stores\ArrayStore;
77
    }
78
79
    /* ------------------------------------------------------------------------------------------------
80
     |  Other Functions
81
     | ------------------------------------------------------------------------------------------------
82
     */
83
    /**
84
     * Get config.
85
     *
86
     * @param  string      $key
87
     * @param  mixed|null  $default
88
     *
89
     * @return string
90
     */
91 9
    protected function getConfig($key, $default = null)
92
    {
93
        /** @var  \Illuminate\Config\Repository  $config */
94 9
        $config = $this->app['config'];
95
96 9
        return $config->get($key, $default);
97
    }
98
}
99