Passed
Push — dev ( f29cfd...d7eff6 )
by Janko
11:00
created

SpacecraftNfsIterator::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Spacecraft\Lib;
6
7
use Iterator;
8
use Override;
0 ignored issues
show
Bug introduced by
The type Override 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...
9
use Stu\Module\Spacecraft\Lib\TSpacecraftItemInterface;
10
11
/**
12
 * @implements Iterator<SpacecraftNfsItem>
13
 *
14
 */
15
final class SpacecraftNfsIterator implements Iterator
16
{
17
    private int $position = 0;
18
19
    /** @param array<TSpacecraftItemInterface> $spacecrafts */
20 1
    public function __construct(private array $spacecrafts, private int $userId) {}
21
22 1
    #[Override]
23
    public function rewind(): void
24
    {
25 1
        $this->position = 0;
26
    }
27
28 1
    #[Override]
29
    public function current(): SpacecraftNfsItem
30
    {
31 1
        return new SpacecraftNfsItem($this->spacecrafts[$this->position], $this->userId);
32
    }
33
34 1
    #[Override]
35
    public function key(): int
36
    {
37 1
        return $this->position;
38
    }
39
40 1
    #[Override]
41
    public function next(): void
42
    {
43 1
        ++$this->position;
44
    }
45
46 1
    #[Override]
47
    public function valid(): bool
48
    {
49 1
        return isset($this->spacecrafts[$this->position]);
50
    }
51
52 1
    public function count(): int
53
    {
54 1
        return count($this->spacecrafts);
55
    }
56
}
57