/** * Constructor... * * @param Integer $offset The offset at which to start iteration * @param \Traversable $inner The iterator being wrapped */ public function __construct($offset, \Traversable $inner) { $this->inner = $inner; $offset = (int) $offset; // If we can, be intelligent about the offset if ($inner instanceof \Countable) { try { $offset = \r8\num\offsetWrap($inner->count(), $offset, \r8\num\OFFSET_NONE); } catch (\r8\Exception\Index $err) { $offset = NULL; } } else { if ($offset < 0) { $err = new \r8\Exception\Index($offset, "Iterator Offset", "Negative offsets are only supported if Iterator implements the Countable interface"); $err->addData("Iterator", \r8\getDump($inner)); throw $err; } } $this->offset = $offset; }