ArrayStorage::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace QueerCodingGirl\Rollout\Storage;
4
5
6
use QueerCodingGirl\Rollout\Interfaces\KeyValueStorageInterface;
7
8
/**
9
 * Class ArrayStorage
10
 * @package QueerCodingGirl\Rollout\Storage
11
 */
12
class ArrayStorage implements KeyValueStorageInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $storage = array();
18
19
    /**
20
     * Gets a value from a key in the storage
21
     *
22
     * @param $key
23
     * @return string|null
24
     */
25
    public function get($key)
26
    {
27
        $storageValue = null;
28
        if (true === array_key_exists($key, $this->storage)) {
29
            $storageValue = $this->storage[$key];
30
        }
31
        return $storageValue;
32
    }
33
34
    /**
35
     * Sets a key in the storage to a value
36
     *
37
     * @param $key
38
     * @param $value
39
     * @return KeyValueStorageInterface
40
     */
41
    public function set($key, $value)
42
    {
43
        $this->storage[$key] = $value;
44
        return $this;
45
    }
46
47
}