Blocks   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A forget() 0 3 1
A get() 0 3 1
A join() 0 3 1
1
<?php
2
/**
3
 * Local memory blocks
4
 * User: moyo
5
 * Date: 2018/7/11
6
 * Time: 12:01 PM
7
 */
8
9
namespace Carno\Cache;
10
11
use Carno\Cache\Stores\Local;
12
13
class Blocks
14
{
15
    /**
16
     * @var Local[]
17
     */
18
    private static $stores = [];
19
20
    /**
21
     * @param int $id
22
     * @return Local
23
     */
24
    public static function get(int $id) : ?Local
25
    {
26
        return self::$stores[$id] ?? null;
27
    }
28
29
    /**
30
     * @param Local $store
31
     * @return Local
32
     */
33
    public static function join(Local $store) : Local
34
    {
35
        return self::$stores[spl_object_id($store)] = $store;
36
    }
37
38
    /**
39
     * @param Local $store
40
     */
41
    public static function forget(Local $store) : void
42
    {
43
        unset(self::$stores[spl_object_id($store)]);
44
    }
45
}
46