ListSinceBlock   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
dl 0
loc 43
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getHashParam() 0 3 2
A jsonSerialize() 0 10 1
A getConfirmsParam() 0 3 3
A getWatchOnlyParam() 0 5 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