| Total Complexity | 7 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Coverage | 91.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Rotation extends Iterators |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * A copy of the original data. |
||
| 16 | * |
||
| 17 | * @var mixed[] |
||
| 18 | */ |
||
| 19 | protected $rotation; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Rotation constructor. |
||
| 23 | * |
||
| 24 | * @param array<int, mixed> $dataset |
||
| 25 | * The dataset |
||
| 26 | */ |
||
| 27 | 5 | public function __construct(array $dataset = []) |
|
| 28 | { |
||
| 29 | 5 | parent::__construct($dataset, null); |
|
| 30 | 5 | $this->rotation = $this->getDataset(); |
|
| 31 | 5 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * {@inheritdoc} |
||
| 35 | */ |
||
| 36 | 5 | public function count() |
|
| 37 | { |
||
| 38 | 5 | return count($this->getDataset()); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | 5 | public function current() |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Compute the next value of the Iterator. |
||
| 51 | * |
||
| 52 | * @param int|null $offset |
||
| 53 | * The offset |
||
| 54 | * |
||
| 55 | * @return void |
||
| 56 | */ |
||
| 57 | 5 | public function next($offset = 1) |
|
| 58 | { |
||
| 59 | 5 | $offset = (null === $offset) ? 1 : $offset % $this->count(); |
|
| 60 | 5 | $this->rotation = array_merge( |
|
| 61 | 5 | array_slice( |
|
| 62 | 5 | $this->rotation, |
|
| 63 | 5 | $offset |
|
| 64 | ), |
||
| 65 | 5 | array_slice( |
|
| 66 | 5 | $this->rotation, |
|
| 67 | 5 | 0, |
|
| 68 | 5 | $offset |
|
| 69 | ) |
||
| 70 | ); |
||
| 71 | 5 | } |
|
| 72 | |||
| 73 | /** |
||
| 74 | * {@inheritdoc} |
||
| 75 | */ |
||
| 76 | 5 | public function rewind() |
|
| 79 | 5 | } |
|
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritdoc} |
||
| 83 | * |
||
| 84 | * @return bool |
||
| 85 | */ |
||
| 86 | public function valid() |
||
| 89 | } |
||
| 90 | } |
||
| 91 |