SafeStorage   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 35
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A storeSafely() 0 4 1
A retrieveSafely() 0 6 2
A __destruct() 0 4 1
1
<?php
2
3
namespace League\Flysystem;
4
5
final class SafeStorage
6
{
7
    /**
8
     * @var string
9
     */
10
    private $hash;
11
12
    /**
13
     * @var array
14
     */
15
    protected static $safeStorage = [];
16
17 102
    public function __construct()
18
    {
19 102
        $this->hash = spl_object_hash($this);
20 102
        static::$safeStorage[$this->hash] = [];
21 102
    }
22
23 84
    public function storeSafely($key, $value)
24
    {
25 84
        static::$safeStorage[$this->hash][$key] = $value;
26 84
    }
27
28 87
    public function retrieveSafely($key)
29
    {
30 87
        if (array_key_exists($key, static::$safeStorage[$this->hash])) {
31 75
            return static::$safeStorage[$this->hash][$key];
32
        }
33 12
    }
34
35 102
    public function __destruct()
36
    {
37 102
        unset(static::$safeStorage[$this->hash]);
38 102
    }
39
}
40