Brings the item number in range of the page.

@param  int $itemNumber
@return int
339280
public function normalizeItemNumber($itemNumber)
    {
        $itemNumber = (int) $itemNumber;

        if ($itemNumber < 1) {
            $itemNumber = 1;
        }

        if ($itemNumber > $this->getItemCountPerPage()) {
            $itemNumber = $this->getItemCountPerPage();
        }

        return $itemNumber;
    }
759506
public function updateIndexTimeByItem(Item $item) : int
    {
        $queryBuilder = $this->getQueryBuilder();
        return (int)$queryBuilder
            ->update($this->table)
            ->set('indexed', time())
            ->where($queryBuilder->expr()->eq('uid', $item->getIndexQueueUid()))
            ->execute();
    }
486366
public function updateHasIndexingPropertiesFlagByItemUid(int $itemUid, bool $hasIndexingPropertiesFlag): int
    {
        $queryBuilder = $this->getQueryBuilder();

        return $queryBuilder
            ->update($this->table)
            ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($itemUid, \PDO::PARAM_INT)))
            ->set('has_indexing_properties', $queryBuilder->createNamedParameter($hasIndexingPropertiesFlag, \PDO::PARAM_INT), false)
            ->execute();
    }
1080385
public function update($itemId, $quantity)
    {
        if ($cartItem = $this->get($itemId)) {
            $cartItem->canChangeQuantity($quantity);
            $cartItem->quantity = $quantity;
            $cartItem->save();
        }

        return $cartItem;
    }
990645
public function increment($itemHash)
    {
        $item = $this->getItem($itemHash);
        $item->qty++;
        $this->update();

        return $item;
    }
150393
public function getSegmentCount($pageNumber = '', $fragmentNumber = '')
    {


        if ($pageNumber == '')
            throw new Exception('page number not specified');

        if ($fragmentNumber == '')
            throw new Exception('fragment number not specified');


        $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/fragments/' . $fragmentNumber;

        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $json = json_decode($responseStream);

        return count($json->TextItems->List);
    }
1039853
public function removeItem($item) {
    if (is_int($item)) {
      $index = $item;
      if ($index < 0) {
        throw new \OutOfBoundsException('index out of bounds');
      }
      $items = $this->getItems();
      if ($index >= count($items)) {
        throw new \OutOfBoundsException('index out of bounds');
      }
      $item = $items[$index];
      $is_last = $index === count($items) - 1;
    }
    else {
      if ($item->parent() !== $this) {
        throw new \InvalidArgumentException('invalid item');
      }
      $items = $this->getItems();
      $last_index = count($items) - 1;
      $last_item = $items[$last_index];
      $is_last = $last_item === $item;
    }
    if (count($items) === 1) {
      // No separators to remove.
    }
    elseif ($is_last) {
      $item->previousUntil(function ($node) {
        if ($node instanceof HiddenNode) {
          return FALSE;
        }
        if ($node instanceof TokenNode && $node->getType() === ',') {
          return FALSE;
        }
        return TRUE;
      })->remove();
    }
    else {
      $item->nextUntil(function ($node) {
        if ($node instanceof HiddenNode) {
          return FALSE;
        }
        if ($node instanceof TokenNode && $node->getType() === ',') {
          return FALSE;
        }
        return TRUE;
      })->remove();
    }
    $item->remove();
    return $this;
  }
922618
public function getTotalPages($totalNumber = null)
    {
        if (is_null($totalNumber)) {
            $totalNumber = $this->totalNumberOfElements;
        }

        return $this->getLimit() ? (ceil($totalNumber / $this->getLimit())) : 1;
    }
79726
public function addToIndex(int $index, $item): bool {
        if (\count($this->array) === $this->size()) {
            $this->ensureCapacity($this->size() * 2 + 1);
        }
        $this->array[$index] = $item;
        $this->size++;
        return true;
    }
340153
protected function getItemsPerPage()
    {
        $perPage = (int)$this->resultSet->getUsedSearch()->getQuery()->getRows();
        return $perPage > 0 ? $perPage : 10;
    }
29170
public function getPageCount($itemClass, Form $form)
	{
		$itemMetaData = $this->itemMetaDataFactory->getItemMetaData($itemClass);
		$query = $this->queryFactory->getQuery($itemMetaData);
		$request = $form->getData();
		$count = ceil($query->getCount($this->em, $request) / $request->getLimit());
		return $count;
	}
92054
public function indexOf($value): ?int
    {
        $i = 0;
        foreach ($this->items as $key => $iValue) {
            if ($value === $iValue) {
                return $i;
            }
            ++$i;
        }

        return null;
    }
490690
protected function addItem(Item $item, int $position = null): Item
	{
		/* @var $this IParent */
		$item->setParent($this);
		if ($position !== null) {
			Arrays::slice($this->items, $position, $item);
		} else {
			$this->items[] = $item;
		}
		return $item;
	}
143387
protected function indexOf($item)
    {
        if (false !== ($index = array_search($item, $this->_data, true)))
            return $index;
        else
            return -1;
    }
576710
public function indexOf( $item ) {

			for ( $i=0; $i < $this->len; $i++ ) {

				if ( $this->compare( $item, $this->items[$i] ) === 0 ) {
					return $i;
				}

			}

			return -1;

		}
211485
protected function NextItem()
	{
		$keys = array_keys( $this->itemSet );

		while ( $this->elementIndex < count( $keys ) )
		{
			/**
			 * @var array $elements
			 */
			$elements = $this->itemSet[ $keys[ $this->elementIndex ] ];

			while ( $this->index < count( $elements ) )
			{
				/**
				 * @var XPathItem $item
				 */
				$item = $elements[ $this->index++ ] ;

				if ( $item instanceof XPathNavigator )
				{
					/**
					 * @var XPathNavigator $node
					 */
					$node = $item;

					if ( ! is_null( $this->lastNode ) )
					{
						if ( $this->lastNode->IsSamePosition( $node ) )
						{
							continue;
						}
					}
					$this->lastNode = $node->CloneInstance();
				}

				return $item;
			}

			$this->elementIndex++;
			$this->index = 0;
			$this->lastNode = null;
		}
		return null;
	}
737612
private function formatOrderNumber($orderNumber)
    {
        $length = strlen($orderNumber);
        $minLength = 4;

        if ($length < $minLength) {
            $orderNumber = str_pad($orderNumber, $minLength, '0', STR_PAD_LEFT);
        }

        return $orderNumber;
    }