for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Boudewijn Schoon <[email protected]>
* @copyright Zicht Online <http://zicht.nl>
*/
namespace Zicht\Itertools\lib;
use Zicht\Itertools\lib\Interfaces\InfiniteIterableInterface;
use Zicht\Itertools\lib\Traits\InfiniteIterableTrait;
* Class RepeatIterator
*
* @package Zicht\Itertools\lib
class RepeatIterator implements \Countable, InfiniteIterableInterface
{
use InfiniteIterableTrait;
/** @var mixed */
private $mixed;
/** @var integer */
private $times;
private $key;
* RepeatIterator constructor.
* @param mixed $mixed
* @param integer $times
public function __construct($mixed, $times)
$this->mixed = $mixed;
$this->times = $times;
$this->key = 0;
}
* @{inheritDoc}
public function rewind()
public function current()
return $this->mixed;
public function key()
return $this->key;
public function next()
$this->key += 1;
public function valid()
return null === $this->times ? true : $this->key < $this->times;
public function count()
return null === $this->times ? -1 : $this->times;