Completed
Pull Request — master (#759)
by thomas
39:27 queued 37:07
created

Creator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createPsbt() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Transaction\PSBT;
6
7
use BitWasp\Bitcoin\Transaction\TransactionInterface;
8
9
class Creator
10
{
11 2
    public function createPsbt(TransactionInterface $tx, array $unknowns = []): PSBT
12
    {
13 2
        $inputs = [];
14 2
        for ($i = 0; $i < count($tx->getInputs()); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
15 2
            $inputs[] = new PSBTInput();
16
        }
17 2
        $outputs = [];
18 2
        for ($i = 0; $i < count($tx->getOutputs()); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
19 2
            $outputs[] = new PSBTOutput();
20
        }
21
22 2
        return new PSBT($tx, $unknowns, $inputs, $outputs);
23
    }
24
}
25