Passed
Push — master ( f7e6da...898aad )
by Pol
13:25
created

Cycle::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace drupol\phpermutations\Iterators;
4
5
use drupol\phpermutations\Combinatorics;
6
7
/**
8
 * Class Cycle.
9
 *
10
 * @package drupol\phpermutations\Iterators
11
 */
12
class Cycle extends Combinatorics implements \Iterator, \Countable {
13
14
  /**
15
   * The key.
16
   *
17
   * @var int
18
   */
19
  protected $key = 0;
20
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function key() {
25
    return $this->key;
26
  }
27 1
28 1
  /**
29 1
   * {@inheritdoc}
30
   */
31
  public function current() {
32
    return $this->dataset[$this->key];
33
  }
34
35
  /**
36
   * {@inheritdoc}
37
   */
38
  public function next() {
39
    $this->key = ($this->key + 1) % $this->datasetCount;
40
  }
41 1
42 1
  /**
43
   * {@inheritdoc}
44
   */
45
  public function rewind() {
46
    $this->key = 0;
47
  }
48 1
49 1
  /**
50 1
   * {@inheritdoc}
51
   */
52
  public function valid() {
53
    return TRUE;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
54
  }
55
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function count() {
60
    return count($this->getDataset());
61
  }
62
63
}
64