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

ListUnspent::jsonSerialize()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

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