for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Trait SeekableIteratorTrait
*
* @filesource SeekableIteratorTrait.php
* @created 04.12.2017
* @package chillerlan\Traits
* @author Smiley <[email protected]>
* @copyright 2017 Smiley
* @license MIT
*/
namespace chillerlan\Traits\SPL;
use chillerlan\Traits\Interfaces\IteratorTrait;
use OutOfBoundsException;
* @extends \Iterator
* @implements \SeekableIterator
* @link http://php.net/manual/class.seekableiterator.php
trait SeekableIteratorTrait{
use IteratorTrait;
* @link http://php.net/manual/seekableiterator.seek.php
* @inheritdoc
public function seek($pos):void{
$this->rewind();
for( ; $this->offset < $pos; ){
if(!\next($this->array)) {
throw new OutOfBoundsException('invalid seek position: '.$pos);
}
$this->offset++;