public function slice($start, $end)
{
if (!is_integer($start) || $start < 0) {
throw new InvalidArgumentException("Start must be a non-negative integer");
}
if (!is_integer($end) || $end < 0) {
throw new InvalidArgumentException("End must be a positive integer");
}
if ($start > $end) {
throw new InvalidArgumentException("End must be greater than start");
}
if ($end > $this->count() + 1) {
throw new InvalidArgumentException("End must be less than the count of the items in the Collection");
}
$length = $end - $start + 1;
$subsetItems = array_slice($this->items, $start, $length);
$col = new static($this->type);
$col->setItemsFromTrustedSource($subsetItems);
return $col;
}