WalletProxy::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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