RawTransaction::jsonSerialize()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 1
nop 0
crap 3
1
<?php
2
3
namespace ZenCash\Rpc\Command\RawTransactions;
4
5
final class RawTransaction implements \JsonSerializable
6
{
7
    private $txid;
8
    private $vout;
9
    private $scriptPubKey;
10
    private $redeemScript;
11
12 9
    public function __construct(string $txid, int $vout, ?string $scriptPubKey, ?string $redeemScript)
13
    {
14 9
        $this->txid = $txid;
15 9
        $this->vout = $vout;
16 9
        $this->scriptPubKey = $scriptPubKey;
17 9
        $this->redeemScript = $redeemScript;
18 9
    }
19
20 5
    public function jsonSerialize(): object
21
    {
22 5
        return (object) array_merge(
23 5
            [ 'txid' => $this->txid, 'vout' => $this->vout ],
24 5
            !is_null($this->scriptPubKey) ? [ 'scriptPubKey' => $this->scriptPubKey ] : [ ],
25 5
            !is_null($this->redeemScript) ? [ 'redeemScript' => $this->redeemScript ] : [ ]
26
        );
27
    }
28
}
29