Test Failed
Pull Request — master (#14)
by Бабичев
02:49
created

WalletProxy::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bavix\Wallet;
4
5
class WalletProxy
6
{
7
8
    /**
9
     * @var array
10
     */
11
    protected static $rows = [];
12
13
    /**
14
     * @param int $key
15
     * @return bool
16
     */
17 19
    public static function has(int $key): bool
18
    {
19 19
        return \array_key_exists($key, static::$rows);
20
    }
21
22
    /**
23
     * @param int $key
24
     * @return int
25
     */
26 19
    public static function get(int $key): int
27
    {
28 19
        return (int) (static::$rows[$key] ?? 0);
29
    }
30
31
    /**
32
     * @param int $key
33
     * @param int $value
34
     * @return bool
35
     */
36 19
    public static function set(int $key, int $value): bool
37
    {
38 19
        static::$rows[$key] = $value;
39 19
        return true;
40
    }
41
42
    /**
43
     * @return void
44
     */
45 21
    public static function fresh(): void
46
    {
47 21
        static::$rows = [];
48 21
    }
49
50
}
51