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

ZImportKey   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A jsonSerialize() 0 7 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