Completed
Push — master ( 458655...206e23 )
by Nathan
02:30
created

ListSinceBlock   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 26
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B jsonSerialize() 0 12 7
A __construct() 0 5 1
1
<?php
2
3
namespace ZenCash\Rpc\Command\Wallet;
4
5
use ZenCash\Rpc\Command;
6
7
class ListSinceBlock implements Command
8
{
9
    private const METHOD = 'listsinceblock';
10
    private $hash;
11
    private $confirms;
12
    private $watchOnly;
13
14 4
    public function __construct(?string $blockHash, ?int $targetConfirmations, ?bool $includeWatchOnly)
15
    {
16 4
        $this->hash = $blockHash;
17 4
        $this->confirms = $targetConfirmations;
18 4
        $this->watchOnly = $includeWatchOnly;
19 4
    }
20
21 4
    public function jsonSerialize(): object
22
    {
23
        return (object) [
24 4
                'jsonrpc' => Command::JSON_RPC_VERSION,
25
                'id'      => Command::ID,
26 4
                'method'  => self::METHOD,
27 4
                'params' => array_merge(
28 4
                    !is_null($this->hash) ? [ $this->hash ] : [ ],
29 4
                    !is_null($this->hash) && !is_null($this->confirms) ? [ $this->confirms ] : [ ],
30 4
                    !is_null($this->hash) && !is_null($this->confirms) && !is_null($this->watchOnly) ? [
31 1
                        $this->watchOnly
32 4
                    ] : [ ]
33
                )
34
        ];
35
    }
36
}
37