Completed
Push — master ( 160801...bd59d4 )
by Andreas
27:08
created

nullcontainer   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 77.27%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 51
ccs 17
cts 22
cp 0.7727
rs 10
c 0
b 0
f 0
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A get_value() 0 3 1
A set_value() 0 3 1
A unlock() 0 3 1
A lock() 0 3 1
A is_locked() 0 3 1
A __construct() 0 12 4
A save() 0 2 1
1
<?php
2
/**
3
 * @copyright CONTENT CONTROL GmbH, http://www.contentcontrol-berlin.de
4
 */
5
6
namespace midcom\datamanager\storage\container;
7
8
use midcom\datamanager\storage\transientnode;
9
use midcom\datamanager\schema;
10
11
/**
12
 * Experimental storage class
13
 */
14
class nullcontainer extends container
15
{
16
    /**
17
     *
18
     * @var mixed
19
     */
20
    protected $value;
21
22 12
    public function __construct(schema $schema, array $defaults)
23
    {
24 12
        $this->schema = $schema;
25
26 12
        foreach ($this->schema->get('fields') as $name => $config) {
27 10
            if (array_key_exists($name, $defaults)) {
28 7
                $config['default'] = $defaults[$name];
29
            }
30 10
            $config['name'] = $name;
31 10
            $this->fields[$name] = new transientnode($config);
32 10
            if (isset($config['default'])) {
33 10
                $this->fields[$name]->set_value($config['default']);
34
            }
35
        }
36 12
    }
37
38 11
    public function lock() : bool
39
    {
40 11
        return true;
41
    }
42
43 3
    public function unlock() : bool
44
    {
45 3
        return true;
46
    }
47
48 11
    public function is_locked() : bool
49
    {
50 11
        return false;
51
    }
52
53
    public function set_value($value)
54
    {
55
        $this->value = $value;
56
    }
57
58
    public function get_value()
59
    {
60
        return $this->value;
61
    }
62
63 2
    public function save()
64
    {
65 2
    }
66
}
67