public function take($count)
{
if ($count == 0) {
return new Linq([]);
}
$innerIterator = $this->iterator;
if (!$innerIterator instanceof \Iterator) {
// IteratorIterator wraps $this->iterator 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, 0, $count));
}