Completed
Pull Request — master (#37)
by Anton
06:21
created

CacheConfig::storeClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6667
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Cache\Configs;
9
10
use Spiral\Core\InjectableConfig;
11
use Spiral\Core\Traits\Config\AliasTrait;
12
13
/**
14
 * Cache component configuration manager.
15
 */
16
class CacheConfig extends InjectableConfig
17
{
18
    use AliasTrait;
19
20
    /**
21
     * Configuration section.
22
     */
23
    const CONFIG = 'cache';
24
25
    /**
26
     * @var array
27
     */
28
    protected $config = [
29
        'store'  => '',
30
        'stores' => []
31
    ];
32
33
    /**
34
     * @param string $store
35
     * @return bool
36
     */
37
    public function hasStore($store)
38
    {
39
        return isset($this->config['stores'][$store]);
40
    }
41
42
    /**
43
     * @param string $store
44
     * @return string
45
     */
46
    public function storeClass($store)
47
    {
48
        if (class_exists($store)) {
49
            //Legacy format support
50
            return $store;
51
        }
52
53
        return $this->config['stores'][$store]['class'];
54
    }
55
56
    /**
57
     * @param string $store
58
     * @return array
59
     */
60
    public function storeOptions($store)
61
    {
62
        return $this->config['stores'][$store];
63
    }
64
}