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

Config::offsetSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
nc 1
cc 1
eloc 2
nop 2
crap 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