public function skip($count)
{
// If its an array iterator we must check the arrays bounds are greater than the skip count.
// This is because the LimitIterator will use the seek() method which will throw an exception if $count > array.bounds.
$innerIterator = $this->iterator;
if ($innerIterator instanceof \ArrayIterator) {
if ($count >= $innerIterator->count()) {
return new Linq([]);
}
}
if (!$innerIterator instanceof \Iterator) {
// IteratorIterator wraps $innerIterator because it is Traversable but not an Iterator.
// (see https://bugs.php.net/bug.php?id=52280)
$innerIterator = new \IteratorIterator($innerIterator);
}
return new Linq(new \LimitIterator($innerIterator, $count, -1));
}