buffered()); } /** * Unserializes the passed string and rebuilds the Collection instance * * @param string $collection The serialized collection * @return void */ public function unserialize($collection) { $this->__construct(unserialize($collection)); } /** * {@inheritDoc} * * @return int */ public function count() { $traversable = $this->optimizeUnwrap(); if (is_array($traversable)) { return count($traversable); } return iterator_count($traversable); } /** * {@inheritDoc} * * @return int */ public function countKeys() { return count($this->toArray()); } /** * Returns an array that can be used to describe the internal state of this * object. * * @return array */ public function __debugInfo() { return [ 'count' => $this->count(), ]; } }