Passed
Push — master ( 2ff4f6...d101d2 )
by Nathan
02:36
created

ListUnspent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 10 2
A __construct() 0 7 1
1
<?php
2
3
namespace ZenCash\Rpc\Command\Wallet;
4
5
use ZenCash\Rpc\Command;
6
7
final class ListUnspent implements Command
8
{
9
    private const METHOD = 'listunspent';
10
    private $addresses;
11
    private $minConf;
12
    private $maxConf;
13
14
    /**
15
     * @param string[] $addresses
16
     * @param int $minConf
17
     * @param int $maxConf
18
     */
19
    public function __construct(array $addresses = [], int $minConf = 1, int $maxConf = 9999999)
20
    {
21
        call_user_func_array(function(string ...$address) {}, $addresses);
22
23 4
        $this->addresses = $addresses;
24 4
        $this->minConf = $minConf;
25 4
        $this->maxConf = $maxConf;
26 4
    }
27
28 4
    public function jsonSerialize(): object
29
    {
30
        return (object) [
31 4
            'jsonrpc' => Command::JSON_RPC_VERSION,
32
            'id'      => Command::ID,
33 4
            'method'  => self::METHOD,
34 4
            'params' => array_merge([
35 4
                $this->minConf,
36 4
                $this->maxConf
37 4
            ], !empty($this->addresses) ? [ $this->addresses ] : [ ])
38
        ];
39
    }
40
}
41