Passed
Push — master ( 17c63b...4d17cd )
by Max
48s queued 12s
created

RpIteratorToArray::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Fakes;
4
5
use Iterator;
6
7
/**
8
 * Repetition which coverts iterator to array multiple times.
9
 * @template TKey
10
 * @template TValue
11
 * @extends RepetitionEnvelope<Iterator<TKey,TValue>, array<array<TKey, TValue>>>
12
 */
13
final class RpIteratorToArray extends RepetitionEnvelope
14
{
15
16
    /**
17
     * Ctor.
18
     *
19
     * @phpstan-param Iterator<TKey, TValue> $source
20
     * @param Iterator $source source iterator.
21
     */
22
    public function __construct(
23
        Iterator $source
24
    ) {
25
        parent::__construct(
26
            $source,
27
            fn (Iterator $source): array => iterator_to_array($source)
28
        );
29
    }
30
}
31