Completed
Push — master ( bff5f7...caa188 )
by Lena
12:09
created

ArrayStorage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 2
A set() 0 5 1
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
}