Completed
Pull Request — master (#38)
by Boris
04:23 queued 02:11
created

Config   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 8
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 41
ccs 20
cts 20
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A offsetExists() 0 4 1
A offsetGet() 0 6 2
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of CacheTool.
5
 *
6
 * (c) Samuel Gordalina <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Console;
13
14
class Config implements \ArrayAccess
15
{
16
    private $config = array(
17
        'adapter' => 'fastcgi',
18
        'fastcgi' => null,
19
        'temp_dir' => null
20
    );
21
22 6
    public function __construct(array $config = array())
23
    {
24 6
        if (!empty($config)) {
25 2
            $this->config = $config;
26
27 2
            if (!isset($this->config['temp_dir'])) {
28 2
                $this->config['temp_dir'] = sys_get_temp_dir();
29 2
            }
30 2
        }
31 6
    }
32
33 6
    public function offsetExists($offset)
34
    {
35 6
        return isset($this->config[$offset]);
36
    }
37
38 4
    public function offsetGet($offset)
39
    {
40 4
        if ($this->offsetExists($offset)) {
41 4
            return $this->config[$offset];
42
        }
43 2
    }
44
45 3
    public function offsetSet($offset, $value)
46
    {
47 3
        $this->config[$offset] = $value;
48 3
    }
49
50 1
    public function offsetUnset($offset)
51
    {
52 1
        unset($this->config[$offset]);
53 1
    }
54
}
55