DataStorageExtension   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 48
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 4 1
A get() 0 4 2
A set() 0 4 1
A remove() 0 4 1
A put() 0 4 1
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Migration\Extension;
4
5
use RDV\Bundle\MigrationBundle\Migration\DataStorageInterface;
6
7
/**
8
 * This extension can be used if you need to exchange data between different migrations
9
 */
10
class DataStorageExtension implements DataStorageInterface
11
{
12
    /** @var array */
13
    protected $data = [];
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function has($key)
19
    {
20
        return array_key_exists($key, $this->data);
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function get($key, $default = null)
27
    {
28
        return $this->has($key) ? $this->data[$key] : $default;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function set($key, $value)
35
    {
36
        $this->data[$key] = $value;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function remove($key)
43
    {
44
        unset($this->data[$key]);
45
    }
46
47
    /**
48
     * @param string $key
49
     * @param mixed  $value
50
     *
51
     * @deprecated since 1.9. use {@see set} method instead
52
     */
53
    public function put($key, $value)
54
    {
55
        $this->data[$key] = $value;
56
    }
57
}
58