@param PackedItem $itemA
@param PackedItem $itemB

@return int
190779
private function compare(PackedItem $itemA, PackedItem $itemB): int
    {
        $itemAVolume = $itemA->getItem()->getWidth() * $itemA->getItem()->getLength() * $itemA->getItem()->getDepth();
        $itemBVolume = $itemB->getItem()->getWidth() * $itemB->getItem()->getLength() * $itemB->getItem()->getDepth();

        return ($itemBVolume <=> $itemAVolume) ?: ($itemB->getItem()->getWeight() <=> $itemA->getItem()->getWeight());
    }
282898
private function getOrderItemVariables($item, $itemId)
    {
        $variables = [];

        if (!$item->isDummy()) {
            $prefix = "order.items.$itemId";
            $variables[$prefix . '.sku']        = $item->getSku();
            $variables[$prefix . '.product_id'] = $item->getProductId();
            $variables[$prefix . '.qty']        = $item->getQtyOrdered();
            $variables[$prefix . '.price']      = $item->getBasePrice();
            $variables[$prefix . '.row_total']  = $item->getRowTotal();
            $variables[$prefix . '.label']      = $item->getName();
            $variables[$prefix . '.salesrules'] = $item->getAppliedRuleIds();

            $product = $item->getProduct();
            if ($product) {
                $categoriesId = $product->getCategoryIds();
                if (count($categoriesId)) {
                    $variables[$prefix . '.category_ids'] = implode(",", $categoriesId);
                }
            }
        }

        return $variables;
    }
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();
    }
492665
public function count($totalItems = true)
    {
        $items = $this->getCart();

        if (!$totalItems) {
            return $items->count();
        }

        $count = 0;

        foreach ($items as $row) {
            $count += $row->qty;
        }

        return $count;
    }
103438
protected function findItem($tableName,$itemId)
  {
    $tableAlias = $this->getTableAlias($tableName);

    $qb = $this->dbConn->createQueryBuilder();
    $qb->select($this->getTableSelects($tableName,$tableAlias));
    $qb->from($tableName,$tableAlias);

    $primaryKeyName = $this->getTablePrimaryKey($tableName);

    $qb->andWhere($primaryKeyName . ' = :' . $primaryKeyName);

    $qb->setParameter($primaryKeyName,$itemId);

    $rows = $qb->execute()->fetchAll();

    return count($rows) === 1 ? $this->extractItem($tableAlias . '__',$rows[0]) : null;
  }
575940
static function i($itemClass, array $itemsA) {
		df_assert(!isset($itemsA[self::FAKE]));
		return new self([self::$P__ITEM_CLASS => $itemClass, self::$P__ITEMS_A => $itemsA]);
	}
536195
public function getNumberOfItemSlots(): int
    {
        if ($this->numberOfItemSlots === self::VALUE_UNLIMITED_SLOTS_DATABASE) {
            $result = self::VALUE_UNLIMITED_SLOTS;
        } else {
            $result = $this->numberOfItemSlots;
        }
        return $result;
    }
1186944
public function set(ItemInterface $item)
    {
        $id = $item->getId();
        $collectionName = $item->getCollection();

        $this->items[$id] = $item;

        if (isset($this->idCollections[$id]) && $this->idCollections[$id] !== $collectionName) {
            throw new \RuntimeException(sprintf('The item with id: "%s" has been registered previously with another collection.', $id));
        }

        if (isset($this->itemCollections[$collectionName]) === false) {
            $this->itemCollections[$collectionName] = [];
        }

        $this->itemCollections[$collectionName][$id] = $item;
        $this->idCollections[$id] = $collectionName;
    }
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;
	}
1005765
public function getItemId(Item $item)
    {
        /* @var $source \AnimeDb\Bundle\CatalogBundle\Entity\Source */
        foreach ($item->getSources() as $source) {
            if (strpos($source->getUrl(), $this->browser->getHost()) === 0 &&
                preg_match(self::REG_ITEM_ID, $source->getUrl(), $match)
            ) {
                return (int)$match['id'];
            }
        }
        return 0;
    }
692122
protected function _setFirstLast($i, $itemCount, array $item = [])
    {
        $item = array_merge(['last' => false, 'first' => false], $item);
        if ($i == 1) {
            $item['first'] = true;
        }

        if ($i == $itemCount) {
            $item['last'] = true;
        }

        return $item;
    }
541245
protected function ItemEqual( $item1, $item2 )
	{
		$xTypeCode = $item1->getSchemaType()->TypeCode;
		$yTypeCode = $item2->getSchemaType()->TypeCode;
		$types = array( XmlTypeCode::Decimal, XmlTypeCode::Float, XmlTypeCode::Double, XmlTypeCode::Integer );

		if ( $xTypeCode == XmlTypeCode::Boolean && $yTypeCode == XmlTypeCode::Boolean )
		{
			$x = $item1->GetTypedValue();
			$y = $item2->GetTypedValue();

			return $x == $y;
		}

		$xIsNumeric = in_array( $xTypeCode, $types );
		$yIsNumeric = in_array( $yTypeCode, $types );

		if ( $xIsNumeric != $yIsNumeric )
		{
			return false;
		}

		if ( ! $xIsNumeric )
		{
			$x = $item1->GetValue();
			$y = $item2->GetValue();

			if ( ! is_null( $this->collation ) && $this->collation == XmlReservedNs::collationCodepoint )
			{
				$x = \normalizer_normalize( $x, \Normalizer::FORM_C );
				$y = \normalizer_normalize( $y, \Normalizer::FORM_C );

				return strcmp( $x, $y );
			}
			else
			{
				return strcoll( $x, $y ) == 0;
			}
		}

		$x = $item1->GetTypedValue();
		$y = $item2->GetTypedValue();

		// Perform comparison of the typed values
		if ( is_double( $x ) && is_nan( $x ) && is_double( $y ) && is_nan( $y ) )
		{
			// BMS 2017-09-13 XFI requires that NaN == NaN returns false
			return false;
		}
		if ( is_double( $x ) && is_infinite( $x ) && is_double( $y ) && is_infinite( $y ) )
		{
			return true;
		}

		if ( $xTypeCode != $yTypeCode )
		{
			// Handle the exceptions
			$exceptions = (
				( $xTypeCode == XmlTypeCode::Integer && in_array( $yTypeCode, $types ) ) ||
				( $yTypeCode == XmlTypeCode::Integer && in_array( $xTypeCode, $types ) ) ||
				( $xTypeCode == XmlTypeCode::Decimal && in_array( $yTypeCode, $types ) ) ||
				( $yTypeCode == XmlTypeCode::Decimal && in_array( $xTypeCode, $types ) )
			);

			if ( ! $exceptions )
			{
				return false;
			}
		}

		if ( ! is_object( $x ) && ! is_object( $y ) )
		{
			if ( $x == $y )
			{
				return true;
			}
		}
		else if ( is_object( $x ) && is_object( $y ) && method_exists( $x, "Equals" ) && method_exists( $y, "Equals" ) )
		{
			if ( $x->Equals( $y ) )
			{
				return true;
			}
		}

		$res;
		$result = ValueProxy::EqValues( $x, $y, $res) && $res;
		return $result;

	}
1179737
private function getManualItemsCount(Collection $collection, int $startOffset, int $endOffset): int
    {
        $manualItemsCount = 0;

        foreach ($collection->getItems() as $item) {
            $itemPosition = $item->getPosition();
            if ($itemPosition < $startOffset || $itemPosition >= $endOffset) {
                continue;
            }

            if ($this->visibilityResolver->isVisible($item) && $item->isValid()) {
                ++$manualItemsCount;
            }
        }

        return $manualItemsCount;
    }
408083
public function getSumOfShippedItemsByItemId($itemId, $includeStatusDeliveryNote)
    {
        try {
            $qb = $this->createQueryBuilder('shipping')
                ->select('sum(shippingItems.quantity) AS shipped')
                ->join('shipping.shippingItems', 'shippingItems')
                ->join('shippingItems.item', 'item', 'WITH', 'item.id = :itemId')
                ->join('shipping.status', 'status')
                ->groupBy('item.id')
                ->where('status.id = :statusId')
                ->setParameter('itemId', $itemId)
                ->setParameter('statusId', ShippingStatus::STATUS_SHIPPED);
            if ($includeStatusDeliveryNote) {
                $qb->orWhere('status.id = :statusId2')
                    ->setParameter('statusId2', ShippingStatus::STATUS_DELIVERY_NOTE);
            }
            return $qb->getQuery()->getSingleScalarResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
1008595
public function removeByID($itemID)
    {
        parent::removeByID($itemID);

        if ($this->getJoinTable() == 'Group_Members') {
            $currentMember = Security::getCurrentUser();
            if (!($currentMember && $currentMember->exists())) {
                return;
            }

            $member = Member::get()->byId($itemID);
            $group = Group::get()->byId($this->getForeignID());

            if (!$group) {
                return;
            }
            if (!$member) {
                return;
            }

            $this->getAuditLogger()->info(sprintf(
                '"%s" (ID: %s) removed Member "%s" (ID: %s) from Group "%s" (ID: %s)',
                $currentMember->Email ?: $currentMember->Title,
                $currentMember->ID,
                $member->Email ?: $member->Title,
                $member->ID,
                $group->Title,
                $group->ID
            ));
        }
    }
924811
public static function sort_custom_menu_items(custom_menu_item $itema, custom_menu_item $itemb) {
        $itema = $itema->get_sort_order();
        $itemb = $itemb->get_sort_order();
        if ($itema == $itemb) {
            return 0;
        }
        return ($itema > $itemb) ? +1 : -1;
    }
1363751
protected function getQueryBuilderForContainsMethods(string $itemType, int $itemUid) : QueryBuilder
    {
        $queryBuilder = $this->getQueryBuilder();
        return $queryBuilder->count('uid')->from($this->table)
            ->andWhere(
                $queryBuilder->expr()->eq('item_type', $queryBuilder->createNamedParameter($itemType)),
                $queryBuilder->expr()->eq('item_uid', $itemUid)
            );
    }