Completed
Pull Request — master (#37)
by Anton
08:01
created

CacheConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 49
wmc 4
lcom 1
cbo 2
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasStore() 0 4 1
A storeClass() 0 9 2
A storeOptions() 0 4 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
}