/** * {@inheritdoc} */ public function randomize() { $randomizedArray = []; for ($this->rewind(); $this->valid(); $this->next()) { $randomizedArray[] = $this->current(); } shuffle($randomizedArray); $newQueue = new self(); foreach ($randomizedArray as $item) { $newQueue->enqueue($item); } return $newQueue; }