ListSinceBlock::getWatchOnlyParam()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 2
nc 6
nop 0
crap 4
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
                    $this->getHashParam(),
29 4
                    $this->getConfirmsParam(),
30 4
                    $this->getWatchOnlyParam()
31
                )
32
        ];
33
    }
34
35 4
    private function getHashParam(): array
36
    {
37 4
        return !is_null($this->hash) ? [ $this->hash ] : [ ];
38
    }
39
40 4
    private function getConfirmsParam(): array
41
    {
42 4
        return !is_null($this->hash) && !is_null($this->confirms) ? [ $this->confirms ] : [ ];
43
    }
44
45 4
    private function getWatchOnlyParam(): array
46
    {
47 4
        return !is_null($this->hash) && !is_null($this->confirms) && !is_null($this->watchOnly) ? [
48 1
            $this->watchOnly
49 4
        ] : [ ];
50
    }
51
}
52