Blocks::join()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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