Completed
Pull Request — master (#2)
by Pedro
02:08
created

Config   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 8
c 4
b 1
f 1
lcom 0
cbo 1
dl 0
loc 63
ccs 16
cts 20
cp 0.8
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 18 5
A getAdapterName() 0 4 1
A getSettings() 0 4 1
A getAdapterNamespace() 0 4 1
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
    public function __construct(array $config)
28
    {
29
        if (!isset($config['adapter_name']) || !is_string($config['adapter_name'])) {
30
            throw new InvalidCacheConfig('Invalid Adapter Name. Is Not A String OR Is Missing!');
31
        }
32
        $this->adapterName = $config['adapter_name'];
33
34
        unset($config['adapter_name']);
35
        $this->settings = $config;
36
37 9
        if (isset($config['adapter_namespace'])) {
38
            if (!is_string($config['adapter_namespace'])) {
39 9
                throw new InvalidCacheConfig('Invalid Adapter Namespace. Is Not A String!');
40 1
            }
41
42 8
            $this->adapterNamespace = $config['adapter_namespace'];
43
        }
44 8
    }
45 1
46
    /**
47 7
     * @return string
48
     */
49 7
    public function getAdapterName()
50 2
    {
51
        return $this->adapterName;
52
    }
53 5
54 1
    /**
55
     * @return array
56 4
     */
57
    public function getSettings()
58 4
    {
59 1
        return $this->settings;
60
    }
61 3
62
    /**
63 3
     * @return string
64
     */
65
    public function getAdapterNamespace()
66
    {
67
        return $this->adapterNamespace;
68
    }
69
}
70