ArrayHashmap::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Maketok\DataMigration\Hashmap;
4
5
use Maketok\DataMigration\HashmapInterface;
6
7
class ArrayHashmap implements HashmapInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $code;
13
    /**
14
     * @var array
15
     */
16
    private $storage;
17
18
    /**
19
     * @param string $code
20
     */
21 12
    public function __construct($code)
22
    {
23 12
        $this->code = $code;
24 12
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function offsetExists($offset)
30
    {
31 2
        return isset($this->storage[$offset]);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 6
    public function offsetGet($offset)
38
    {
39 6
        return isset($this->storage[$offset]) ? $this->storage[$offset] : null;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function offsetSet($offset, $value)
46
    {
47 3
        $this->storage[$offset] = $value;
48 3
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    public function offsetUnset($offset)
54
    {
55 1
        $this->storage[$offset] = null;
56 1
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 5
    public function load(array $storage = [])
62
    {
63 5
        $this->storage = $storage;
64 5
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 2
    public function __get($offset)
70
    {
71 2
        return $this->offsetGet($offset);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 2
    public function __set($offset, $value)
78
    {
79 2
        $this->offsetSet($offset, $value);
80 2
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 8
    public function getCode()
86
    {
87 8
        return $this->code;
88
    }
89
}
90