@param array|\Traversable $items

@throws \InvalidArgumentException
183527
private function checkItems($items)
    {
        foreach ($items as $item) {
            if ($this->isItemValid($item)) {
                continue;
            }

            throw new \InvalidArgumentException(sprintf(
                'At least one item in collection "%s" is invalid.',
                get_class($this)
            ));
        }
    }
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);
            }
        }
    }
170223
public function replace(array $items = [])
    {
        $this->items = [];

        foreach ($items as $key => $item) {
            $this->set($key, $item);
        }
    }
25558
public function foreverMany(array $items)
    {
        $items = array_combine(
            $this->prefixKeys(array_keys($items)),
            array_map(function ($value) {
                return is_numeric($value) ? $value : serialize($value);
            }, array_values($items))
        );

        $this->connection()->mset($items);
    }
1229021
public function push(... $items) : Stack
    {
        $values = $this->_pushAll($items);
        $this->setValues($values);
        return $this;
    }
1008082
public function setItemsAttribute($items)
    {
        if (!is_array($items)) {
            throw new \InvalidArgumentException('Items must be an array');
        }

        foreach ($items as $key => $item) {
            if (!($item instanceof Item)) {
                $items[$key] = new Item($item);
            }
        }

        $this->attributes['Items'] = $items;

        return $this;
    }
805661
protected function parseItems($items)
    {
        $items = $items instanceof Traversable ? $items->toArray() : $items;

        return array_map(function ($item) {
            return $item instanceof ScanEntity ? $item : new ScanEntity($item);
        }, $items);
    }
780616
public function setItems(array $items) : self {
      foreach ($items as $item) {
        if (!($item instanceof Token)) {
          throw new \InvalidArgumentException('Expect array of tokens. Token[]');
        }
      }

      $this->items = $items;
      $this->rewind();
      return $this;
    }
1002130
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->doClean($item);
        }

        return $items;
    }
345532
public function configure($items, $handler)
    {
        if (!is_callable($handler)) {
            throw new \InvalidArgumentException(__METHOD__ . ' Handler should be callable.');
        }

        if (!$items instanceof \Traversable && !is_array($items)) {
            throw new \InvalidArgumentException(__METHOD__ . ' items should be array or iterator.');
        }

        foreach ($items as $key => $item) {
            call_user_func($handler, $this, $key, $item);
        }

        return $this;
    }
1302263
public function addRepositories($repositories)
    {
        if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' .
                ' "%s" given',
                is_object($repositories) ? get_class($repositories) : gettype($repositories)
            ));
        }
        foreach ($repositories as $repo) {
            $this->addRepository($repo);
        }
    }
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 );
	}
1155515
public function update(array &$items = [])
    {
        !is_null($this->cache) && $this->cache->forget($this->cacheKey);
        $items['terminate'] = $this->finish($items);
    }
887033
public function loadFromArray(array $items)
    {
        foreach ($items as $item) {
            if (is_array($item) && ! empty($item)) {
                $this->add($item);
            }
        }

        return $this;
    }
614421
public function remove($items)
    {
        if (!is_array($items)) {
            $items = array($items);
        }

        $allItems = $this->getAll();

        foreach ($items as $item) {
            $existingIndex = array_search($item, $allItems);
            if ($existingIndex === false) {
                return;
            }

            unset($allItems[$existingIndex]);
        }

        $this->setAll(array_values($allItems));
    }
541454
public function intersectKeys(iterable $items): self
    {
        $items = Factory::getArrayForItems($items);

        return Factory::create(array_intersect_key($this->items, $items));
    }
33518
public function each($items, callable $callback = null)
    {
        if ($items instanceof \Traversable) {
            $items = iterator_to_array($items);
        }

        $total = count($items);
        if (!$total) {
            return;
        }
        $this->total($total);

        foreach ($items as $key => $item) {
            if ($callback) {
                $label = $callback($item, $key);
            } else {
                $label = null;
            }

            $this->advance(1, $label);
        }
    }