@param Item $itemA
@param Item $itemB

@return int
967467
private function compare(Item $itemA, Item $itemB): int
    {
        $itemAVolume = $itemA->getWidth() * $itemA->getLength() * $itemA->getDepth();
        $itemBVolume = $itemB->getWidth() * $itemB->getLength() * $itemB->getDepth();
        $volumeDecider = $itemAVolume <=> $itemBVolume;
        $weightDecider = $itemA->getWeight() - $itemB->getWeight();
        if ($volumeDecider !== 0) {
            return $volumeDecider;
        }
        if ($weightDecider !== 0) {
            return $weightDecider;
        }

        return $itemB->getDescription() <=> $itemA->getDescription();
    }
804846
public function getErrorInfo(array $itemArray, array $itemInfo)
    {
        $errorInfo            = parent::getErrorInfo($itemArray, $itemInfo);
        $errorInfo['error']   = false; // Warning, not error.
        $errorInfo['message'] = '';

        if (empty($itemArray['message']) === false) {
            $errorInfo['message'] = $itemArray['message'];
        }

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

        return $item;
    }
603454
protected function handleItemsCount($item)
    {
        if ($item->route
            && 'scaffold.index' === array_get($item->route, 0)
            && $module = array_get($item->route, '1.module')
        ) {
            $module = app('scaffold.module.'.$module);

            if ($count = $module->appendCount()) {
                $item->count = $count;
            }
        }

        return $item;
    }
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;
  }
184006
private function getItems($itemValues, string $itemType): array
    {
        $items = [];

        foreach ((array) $itemValues as $itemValue) {
            try {
                $backend = $this->backendRegistry->getBackend($itemType);
                $item = $backend->loadItem($itemValue);
                $items[$item->getValue()] = $item;
            } catch (NotFoundException $e) {
                // Do nothing
            }
        }

        return $items;
    }
218526
public function addItem(Item $item)
    {
        if (!$this->items->contains($item)) {
            $this->items->add($item);
            $item->addLabel($this);
        }

        return $this;
    }
1080385
public function update($itemId, $quantity)
    {
        if ($cartItem = $this->get($itemId)) {
            $cartItem->canChangeQuantity($quantity);
            $cartItem->quantity = $quantity;
            $cartItem->save();
        }

        return $cartItem;
    }
876833
public function hasVoted($item_type, $item_id, $user_id=null, $ip=null)
	{
		return self::oneByScope($item_type, $item_id, $user_id, $ip)->get('id');
	}
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;
    }
546200
public function count($key = null)
	{
		if (!is_null($key) && isset($this->items[$key])) {
			return count($this->items[$key]);
		} else {
			return count($this->items);
		}
	}
433894
protected function _count($items)
    {
        foreach ($items as $item) {
            $this->_count++;
            $item = is_array($item) ? new Entity($item) : $item;

            if ($item->has('children') && !empty($item->children) && $item->expanded) {
                $this->_count($item->children);
            }
        }
    }
977787
public function getItem($itemId)
	{
		if (isset($this->info['data'][$itemId]))
		{
			return $this->info['data'][$itemId];
		}

		return null;
	}
576710
public function indexOf( $item ) {

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

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

			}

			return -1;

		}
855734
public function update ($item_id, array $data) {
		return $this->api->update($this->list_name, $item_id, $data);
	}
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;
	}
1089066
public function countItems(&$items, $extension)
	{
		$parts = explode('.', $extension);
		$component = $parts[0];
		$section = null;

		if (count($parts) > 1)
		{
			$section = $parts[1];
		}

		// Try to find the component helper.
		$eName = str_replace('com_', '', $component);
		$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

		if (file_exists($file))
		{
			require_once $file;

			$prefix = ucfirst($eName);
			$cName = $prefix . 'Helper';

			if (class_exists($cName) && is_callable(array($cName, 'countItems')))
			{
				$cName::countItems($items, $section);
			}
		}
	}