Passed
Push — main ( dca22c...13bf01 )
by Pol
03:14
created

IterableIterator::rewind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types=1);
9
10
namespace loophp\iterators;
11
12
use Generator;
13
use Iterator;
14
use ReturnTypeWillChange;
15
16
/**
17
 * @template TKey
18
 * @template T
19
 *
20
 * @implements Iterator<TKey, T>
21
 */
22
final class IterableIterator implements Iterator
23
{
24
    /**
25
     * @var Iterator<TKey, T>
26
     */
27
    private Iterator $iterator;
28
29
    /**
30
     * @param iterable<TKey, T> $iterable
31
     */
32 7
    public function __construct(iterable $iterable)
33
    {
34 7
        $this->iterator = new ClosureIterator(
35
            /**
36
             * @param iterable<TKey, T> $iterable
37
             *
38
             * @return Generator<TKey, T>
39
             */
40 7
            static fn (iterable $iterable): Generator => yield from $iterable,
41 7
            [$iterable]
42
        );
43 7
    }
44
45
    /**
46
     * @return T
0 ignored issues
show
Bug introduced by
The type loophp\iterators\T was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
     */
48 5
    #[ReturnTypeWillChange]
49
    public function current()
50
    {
51 5
        return $this->iterator->current();
52
    }
53
54
    /**
55
     * @return TKey
0 ignored issues
show
Bug introduced by
The type loophp\iterators\TKey was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56
     */
57 2
    #[ReturnTypeWillChange]
58
    public function key()
59
    {
60 2
        return $this->iterator->key();
61
    }
62
63 4
    public function next(): void
64
    {
65 4
        $this->iterator->next();
66 4
    }
67
68 1
    public function rewind(): void
69
    {
70 1
        $this->iterator->rewind();
71 1
    }
72
73 4
    public function valid(): bool
74
    {
75 4
        return $this->iterator->valid();
76
    }
77
}
78