StorageRuntime::drop()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebComplete\microDb;
4
5
class StorageRuntime implements StorageInterface
6
{
7
8
    /**
9
     * @var array
10
     */
11
    protected static $mem = [];
12
    /**
13
     * @var string
14
     */
15
    protected $file;
16
17
    /**
18
     * @param string $file
19
     */
20
    public function __construct(string $file)
21
    {
22
        $this->file = $file;
23
    }
24
25
    /**
26
     * @param bool $lock
27
     *
28
     * @return array
29
     */
30
    public function load(bool $lock): array
31
    {
32
        return static::$mem[$this->file] ?? [];
33
    }
34
35
    /**
36
     * @param array $collectionData
37
     */
38
    public function save(array $collectionData)
39
    {
40
        static::$mem[$this->file] = $collectionData;
41
    }
42
43
    /**
44
     */
45
    public static function clear()
46
    {
47
        static::$mem = [];
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public static function dump(): array
54
    {
55
        return static::$mem;
56
    }
57
58
    /**
59
     */
60
    public function drop()
61
    {
62
        unset(static::$mem[$this->file]);
63
    }
64
}
65