Cycle   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 5
c 1
b 0
f 0
dl 0
loc 44
ccs 7
cts 12
cp 0.5833
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A rewind() 0 3 1
A valid() 0 3 1
A next() 0 3 1
A count() 0 3 1
A current() 0 3 1
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