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

ListUnspent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 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