Completed
Push — master ( 04d071...ca1502 )
by Nathan
02:43
created

SetGenerate::jsonSerialize()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace ZenCash\Rpc\Command\Generating;
4
5
use ZenCash\Rpc\Command;
6
7
class SetGenerate implements Command
8
{
9
    private const METHOD = 'setgenerate';
10
    private $generate;
11
    private $limit;
12
13
    public function __construct(bool $generate, ?int $genProcLimit)
14
    {
15
        $this->generate = $generate;
16
        $this->limit = $genProcLimit;
17
    }
18
19
    public function jsonSerialize(): object
20
    {
21
        return (object) [
22
            'jsonrpc' => Command::JSON_RPC_VERSION,
23
            'id'      => Command::ID,
24
            'method'  => self::METHOD,
25
            'params' => array_merge([$this->generate], !is_null($this->limit) ? [$this->limit] : [])
26
        ];
27
    }
28
}
29