for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace drupol\phpermutations\Iterators;
use drupol\phpermutations\Iterators;
use function array_slice;
use function count;
class Rotation extends Iterators
{
/**
* A copy of the original data.
*
* @var mixed[]
*/
protected $rotation;
* Rotation constructor.
* @param array<int, mixed> $dataset
* The dataset
public function __construct(array $dataset = [])
parent::__construct($dataset, null);
$this->rotation = $this->getDataset();
}
* {@inheritdoc}
public function count(): int
return count($this->getDataset());
public function current(): mixed
return $this->rotation;
* Compute the next value of the Iterator.
* @param int|null $offset
* The offset
* @return void
public function next($offset = 1): void
$offset = (null === $offset) ? 1 : $offset % $this->count();
$this->rotation = array_merge(
array_slice(
$this->rotation,
$offset
),
0,
)
);
public function rewind(): void
* @return bool
public function valid(): bool
return true;