WalletProxy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 43
rs 10
ccs 9
cts 9
cp 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A get() 0 3 1
A fresh() 0 3 1
A set() 0 4 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