Normalizes and validates an offset

@param int $offset The offset value
@param int $total  The total count

@return int

@throws DomainException When the offset is out of bounds
16924
protected function prepareOffset(int $offset, int $total): int
    {
        if ($offset < -$total || $offset > $total - 1) {
            $message = sprintf('Offset (%d) out of range[%d, %d]', $offset, -$total, $total - 1);
            throw new DomainException($message);
        }

        if ($offset < 0) {
            $offset += $total;
        }

        return $offset;
    }
838127
private static long getNextPageOffset(final int offset, final int limit, final long total) {
        return hasFullNextPage(offset, limit, total) ? getNextFullPageOffset(offset, limit) : getLastPageOffset(total, limit);
    }
125341
private function computeTotalCount($total, array $callableArgs = [])
    {
        if (null !== $this->totalCount) {
            return $this->totalCount;
        }

        $this->totalCount = \is_callable($total) ? \call_user_func_array($total, $callableArgs) : $total;

        return $this->totalCount;
    }
114392
public function getTotal($offset = null)
    {
        if (isset($offset)) {
            return $this->total->offsetGet($offset);
        }

        return $this->total;
    }
1244151
public function setTotalUnreadCount($totalUnreadCount)
    {

        if (!is_null($totalUnreadCount) && ($totalUnreadCount < 0)) {
            throw new \InvalidArgumentException('invalid value for $totalUnreadCount when calling GetCharactersCharacterIdMailLabelsOk., must be bigger than or equal to 0.');
        }

        $this->container['totalUnreadCount'] = $totalUnreadCount;

        return $this;
    }
1153654
public function offsetUnset($offset)
    {
        if (!$this->offsetExists($offset)) {
            throw new \InvalidArgumentException(
                sprintf('Identifier "%s" is not defined.', $offset)
            );
        }

        unset($this->data[$offset]);
    }
538010
public function offsetUnset($offset)
    {
        $this->tags = array_filter($this->tags, function ($tag) use ($offset) {
            return $tag !== $offset->getValue();
        });
    }
407852
public function offsetGet($offset)
    {
        $translatedOffset = $this->validateArgumentExistence($offset);
        if ($translatedOffset === false) {
            throw new \Neos\Flow\Mvc\Exception\NoSuchArgumentException('An argument "' . $offset . '" does not exist.', 1216909923);
        }
        return parent::offsetGet($translatedOffset);
    }
295443
public function offset($offset)
    {
        $offset = (int)$offset;
        $offset < 0 && $offset = 0;
        return $this->add('offset', $offset);
    }
536340
public function offsetUnset($offset)
    {
        if (gettype($offset) === 'string') {
            $data = &$this->getDataPlaceHolder();
            if (isset($data[$offset])) {
                $data[$offset]->detach($this);
                unset($data[$offset]);
            }
        } else {
            $msg = "The requested offset must be a non-empty string.";
            throw new OutOfRangeException($msg);
        }
    }
933166
private function limitOffset($limit, $offset)
    {
        if (!$this->withoutTotalResultCount && !$this->count()) {
            return false;
        }

        $this->queryBuilder
            ->setFirstResult($offset)
            ->setMaxResults($limit);

        return true;
    }
970204
public function offsetSet($offset, $value)
    {
        if (!($value instanceof Result)) {
            throw new InvalidException('ResultSet is a collection of Result only.');
        }

        if (!isset($this->_results[$offset])) {
            throw new InvalidException('Offset does not exist.');
        }

        $this->_results[$offset] = $value;
    }
363296
public function offsetUnset($offset) {
    if (!$this->offsetExists($offset)) {
      throw new RangeException("Var $offset doesn't exists in Web2All_Manager_Registry");
      return false;
    }
    unset($this->vars[$offset]);
    return true;
  }
995368
public function offsetGet($offset)
    {
        if (!is_scalar($offset)) {
            throw new InvalidArgumentException('scalar', 0);
        }
        if (!$this->offsetExists($offset)) {
            throw new \DomainException("$offset is not set");
        }
        return $this->children[$offset];
    }
187036
private function parseOffset($offset)
    {
        if ($offset === 'null') {
            $offset = 0;
        } elseif (is_numeric($offset)) {
            $offset = (int) $offset;
        }

        return $offset;
    }
1314456
public function offsetUnset($offset)
    {
        if ($this->offsetExists($offset)) {
            unset($this->collection[$offset]);
            $this->collectionCount--;
        }
    }
989813
public function offsetUnset($offset)
    {
        if ($this->offsetExists($offset)) {
            $method = 'set'.static::formatOffset($offset);
            $this->{$method}(null);
        }
    }