Completed
Push — master ( 93c645...6f793c )
by Pedro
03:18
created

Config::__construct()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.0187

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 11
cp 0.9091
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 4
nop 1
crap 5.0187
1
<?php
2
3
namespace Pcelta\Doctrine\Cache\Entity;
4
5
use Pcelta\Doctrine\Cache\Exception\InvalidCacheConfig;
6
7
class Config
8
{
9
    /**
10
     * @var string
11
     */
12
    private $adapterName;
13
14
    /**
15
     * @var string
16
     */
17
    private $adapterNamespace = '\Doctrine\Common\Cache\%sCache';
18
19
    /**
20
     * @var array
21
     */
22
    private $settings = [];
23
24
    /**
25
     * @param array $config
26
     */
27 6
    public function __construct(array $config)
28
    {
29 6
        if (!isset($config['adapter_name']) || !is_string($config['adapter_name'])) {
30 1
            throw new InvalidCacheConfig('Invalid Adapter Name. Is Not A String OR Is Missing!');
31
        }
32 5
        $this->adapterName = $config['adapter_name'];
33
34 5
        unset($config['adapter_name']);
35 5
        $this->settings = $config;
36
37 5
        if (isset($config['adapter_namespace'])) {
38 1
            if (!is_string($config['adapter_namespace'])) {
39 1
                throw new InvalidCacheConfig('Invalid Adapter Namespace. Is Not A String!');
40
            }
41
42
            $this->adapterNamespace = $config['adapter_namespace'];
43
        }
44 4
    }
45
46
    /**
47
     * @return string
48
     */
49 3
    public function getAdapterName()
50
    {
51 3
        return $this->adapterName;
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getSettings()
58
    {
59
        return $this->settings;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 2
    public function getAdapterNamespace()
66
    {
67 2
        return $this->adapterNamespace;
68
    }
69
}
70