Completed
Push — master ( c14c4e...abb44b )
by Nathan
02:08
created

CreateRawTransaction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ZenCash\Rpc\Command\RawTransactions;
4
5
use ZenCash\Rpc\Command;
6
7
final class CreateRawTransaction implements Command
8
{
9
    private const METHOD = 'createrawtransaction';
10
    private $transactions;
11
    private $recipients;
12
13
    /**
14
     * @param RawTransaction[] $transactions
15
     * @param Recipient[] $recipients
16
     */
17
    public function __construct(array $transactions, array $recipients)
18
    {
19
        call_user_func_array(function (RawTransaction ...$t) {}, $transactions);
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
        call_user_func_array(function (/** @scrutinizer ignore-unused */ RawTransaction ...$t) {}, $transactions);

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
        call_user_func_array(function (Recipient ...$r) {}, $recipients);
0 ignored issues
show
Unused Code introduced by
The parameter $r is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

20
        call_user_func_array(function (/** @scrutinizer ignore-unused */ Recipient ...$r) {}, $recipients);

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
22 2
        $this->transactions = $transactions;
23 2
        $this->recipients = $recipients;
24 2
    }
25
26 2
    public function jsonSerialize(): object
27
    {
28 2
        $addresses = [];
29
30 2
        foreach ($this->recipients as $recipient) {
31 2
            $addresses = array_merge($addresses, (array) $recipient->jsonSerialize());
32
        }
33
34
        return (object) [
35 2
            'jsonrpc' => Command::JSON_RPC_VERSION,
36
            'id'      => Command::ID,
37 2
            'method'  => self::METHOD,
38 2
            'params' => [ $this->transactions, (object) $addresses ]
39
        ];
40
    }
41
}
42