public function fetchFromOffset($offset, $count = 0, $deleteFromServer = false)
{
if ($count < 0) {
throw new ezcMailInvalidLimitException($offset, $count);
}
if ($this->options->uidReferencing) {
$messages = array_values($this->listUniqueIdentifiers());
$ids = array_flip($messages);
if ($count === 0) {
$count = count($messages);
}
if (!isset($ids[$offset])) {
throw new ezcMailOffsetOutOfRangeException($offset, $count);
}
$range = array();
for ($i = $ids[$offset]; $i < min($count, count($messages)); $i++) {
$range[] = $messages[$i];
}
} else {
$messages = array_keys($this->listMessages());
if ($count === 0) {
$count = count($messages);
}
$range = array_slice($messages, $offset - 1, $count, true);
if (!isset($range[$offset - 1])) {
throw new ezcMailOffsetOutOfRangeException($offset, $count);
}
}
return new ezcMailImapSet($this->connection, $range, $deleteFromServer, array('uidReferencing' => $this->options->uidReferencing));
}