Completed
Push — master ( fbf90c...4b9b70 )
by Nathan
02:48 queued 39s
created

ZImportKey::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ZenCash\Rpc\Command\Wallet;
4
5
use ZenCash\Rpc\Command;
6
use ZenCash\Rpc\Command\Wallet\ZImportKey\Rescan;
7
8
final class ZImportKey implements Command
9
{
10
    private const METHOD = 'z_importkey';
11
    private $zkey;
12
    private $rescan;
13
    private $startHeight;
14
15 3
    public function __construct(string $zkey, ?Rescan $rescan, int $startHeight = 0)
16
    {
17 3
        $this->zkey = $zkey;
18 3
        $this->rescan = $rescan ?: Rescan::WHEN_KEY_IS_NEW();
19 3
        $this->startHeight = $startHeight;
20 3
    }
21
22 3
    public function jsonSerialize(): object
23
    {
24
        return (object) [
25 3
            'jsonrpc' => Command::JSON_RPC_VERSION,
26
            'id'      => Command::ID,
27 3
            'method'  => self::METHOD,
28 3
            'params' => [ $this->zkey, (string) $this->rescan, $this->startHeight ]
29
        ];
30
    }
31
}
32