Internal method for counting items in menu.

This method will ignore children if parent has been marked as `do no expand`.

@param \Cake\ORM\Query $items Items to count
@return int
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);
            }
        }
    }
655966
public function count($params) {
        $orm = !is_null($params['ormObject']) ? $params['ormObject'] : ORM::for_table($params['table']);

        return $orm->count();
    }
868979
protected function renderMenu($items) {
		
		$n = count($items);

		if ($n > 0) {
			echo CHtml::openTag('ul', $this->htmlOptions) . "\n";

			$count = 0;
			foreach ($items as $item) {
				$count++;

				if (isset($item['divider'])) {
					echo "<li class=\"{$this->getDividerCssClass()}\"></li>\n";
				} else {
					$options = isset($item['itemOptions']) ? $item['itemOptions'] : array();
					$classes = array();

					if ($item['active'] && $this->activeCssClass != '') {
						$classes[] = $this->activeCssClass;
					}

					if ($count === 1 && $this->firstItemCssClass !== null) {
						$classes[] = $this->firstItemCssClass;
					}

					if ($count === $n && $this->lastItemCssClass !== null) {
						$classes[] = $this->lastItemCssClass;
					}

					if ($this->itemCssClass !== null) {
						$classes[] = $this->itemCssClass;
					}

					if (isset($item['items'])) {
						$classes[] = $this->getDropdownCssClass();
					}

					if (isset($item['disabled'])) {
						$classes[] = 'disabled';
					}

					if (!empty($classes)) {
						$classes = implode(' ', $classes);
						if (!empty($options['class'])) {
							$options['class'] .= ' ' . $classes;
						} else {
							$options['class'] = $classes;
						}
					}

					echo CHtml::openTag('li', $options) . "\n";

					$menu = $this->renderMenuItem($item);

					if (isset($this->itemTemplate) || isset($item['template'])) {
						$template = isset($item['template']) ? $item['template'] : $this->itemTemplate;
						echo strtr($template, array('{menu}' => $menu));
					} else {
						echo $menu;
					}

					if (isset($item['items']) && !empty($item['items'])) {
						$dropdownOptions = array(
							'encodeLabel' => false,
							'htmlOptions' => isset($item['submenuOptions']) ? $item['submenuOptions']
								: $this->submenuHtmlOptions,
							'items' => $item['items'],
						);
						$dropdownOptions['id'] = isset($dropdownOptions['htmlOptions']['id']) ? 
							$dropdownOptions['htmlOptions']['id'] : null;
						$this->controller->widget('booster.widgets.TbDropdown', $dropdownOptions);
					}

					echo "</li>\n";
				}
			}

			echo "</ul>\n";
		}
	}
24702
public function process(array $items)
    {
        if (!$this->limit) {
            return $items;
        }
        $total = count($items);
        if ($this->limit > $total) {
            return $items;
        }
        for ($i = $this->limit; $i < $total; $i++) {
            if (isset($items[$i])) {
                unset($items[$i]);
            }
        }

        return $items;
    }
466935
public static int getFlattenedItemsCount(final Object... items) {

        return stream(items)
            .map(item -> item.getClass().isArray() ? getFlattenedItemsCount((Object[]) item) : 1)
            .reduce(0, Integer::sum);
    }
548569
public function getContentfulEntriesCount(?Client $client = null, ?Query $query = null): int
    {
        $client = $client ?? $this->defaultClient;

        return count($client->getEntries($query));
    }
908533
protected function setColumnCountViaArray($items)
    {
        $counts = array_map(function ($arr) {
            return count($arr);
        }, $items);

        $this->column_count = max($counts);
    }
78994
public function countTotal($menuItemId = null)
    {
        $qb = $this->getQueryBuilder()
            ->select('COUNT(m)');

        if (!is_null($menuItemId)) {
            $qb->where('m.parentMenuItem = :menuItem_id')
                ->setParameter('menuItem_id', $menuItemId);
        }

        return $qb->getQuery()->getSingleScalarResult();
    }
228667
public function count(...$arguments): ?int
    {
        $where       = $arguments[0] ?? null;
        $whereParams = $arguments[1] ?? null;

        $query = $this->initQueryBuilder();
        try {
            $query->select('1');

            if ($where != null) {
                $query->where($where, $whereParams);
            }

            return $query->count();
        } catch (\Exception $e) {
            $this->setFail($e);

            return null;
        }
    }
1136628
public function countMenuChildren()
	{
		static $children;

		if (!isset($children))
		{
			$menu = \App::get('menu');
			$active = $menu->getActive();
			if ($active)
			{
				$dbo = \App::get('db');

				$query = $dbo->getQuery();
				$query
					->select('id', null, true)
					->from('#__menu')
					->whereEquals('parent_id', $active->id)
					->whereEquals('published', '1');

				$dbo->setQuery($query->toString());
				$children = $dbo->loadResult();
			}
			else
			{
				$children = 0;
			}
		}

		return $children;
	}
244099
public function setItemList( $items )
	{
		if( !is_array( $items ) )
			throw new Exception( 'Item List must be an Array.' );
		$this->items	= array();
		foreach( $items as $item )
			$this->addItem( $item );
	}
1057605
public function count($totalItems = true)
        {
            $cart = $this->getContent();

            if(false === $totalItems) {
                return count($cart->_fields);
            }

            $count = 0;

            foreach($cart->_fields as $rowId) {
                $row = $cart->$rowId;
                $count += $row->qty;
            }

            return $count;
        }
546208
public function count($columns = null)
    {
        $this->compileWheres();
        $result = $this->query->count();

        return (int) $result;
    }
1109508
private function _countItemsInCategory($table, $catid)
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);

		// Count the items in this category
		$query->select('COUNT(id)')
			->from($table)
			->where('catid = ' . $catid);
		$db->setQuery($query);

		try
		{
			$count = $db->loadResult();
		}
		catch (RuntimeException $e)
		{
			JError::raiseWarning(500, $e->getMessage());

			return false;
		}

		return $count;
	}
247967
public function getNumItems($recursive = false)
	{
		if ($recursive)
		{
			$count = $this->numitems;

			foreach ($this->getChildren() as $child)
			{
				$count = $count + $child->getNumItems(true);
			}

			return $count;
		}

		return $this->numitems;
	}
1057897
private function countItems(string $identifier, array $array = []): int
    {
        if (! $array) {
            $array   = $this->toArray($this->all($identifier));
            $counter = count($array);
        } else {
            $counter = 0;
        }

        foreach ($array as $value) {
            $counter += count($value['children']);

            if ($value['children']) {
                $counter += $this->countItems($identifier, $value['children']);
            }
        }

        return $counter;
    }
1363458
protected function formatMenuItems(&$items)
    {
        foreach ( $items as $key => $item ) {
            $itemData = array_only($item->toArray(), $this->selectFields);

            if( ! $item->children->isEmpty() ) {
                $itemData['children'] = $this->sortByField(
                    $this->formatMenuItems($item->children)
                );
            }

            $items[$key] = $itemData;
        }

        return $items;
    }