Conditions | 3 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
11 | 2 | public function createPsbt(TransactionInterface $tx, array $unknowns = []): PSBT |
|
12 | { |
||
13 | 2 | $inputs = []; |
|
14 | 2 | for ($i = 0; $i < count($tx->getInputs()); $i++) { |
|
|
|||
15 | 2 | $inputs[] = new PSBTInput(); |
|
16 | } |
||
17 | 2 | $outputs = []; |
|
18 | 2 | for ($i = 0; $i < count($tx->getOutputs()); $i++) { |
|
19 | 2 | $outputs[] = new PSBTOutput(); |
|
20 | } |
||
21 | |||
22 | 2 | return new PSBT($tx, $unknowns, $inputs, $outputs); |
|
23 | } |
||
25 |
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: