Cycle::rewind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\phpermutations\Iterators;
6
7
use drupol\phpermutations\Iterators;
8
9
use function count;
10
11
class Cycle extends Iterators
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 3
    public function count(): int
17
    {
18 3
        return count($this->getDataset());
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 3
    public function current(): mixed
25
    {
26 3
        return $this->dataset[$this->key];
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @return void
33
     */
34 3
    public function next()
35
    {
36 3
        $this->key = ($this->key + 1) % $this->datasetCount;
37 3
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function rewind(): void
43
    {
44
        $this->key = 0;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     *
50
     * @return bool
51
     */
52
    public function valid(): bool
53
    {
54
        return true;
55
    }
56
}
57