public function testEnqueueAndDequeueToArray() { $this->coll->enqueue('testing1'); $this->coll->enqueue('testing2'); $this->coll->enqueue('testing3'); $this->coll->dequeue(); $this->assertEquals(array('testing2', 'testing3'), $this->coll->toArray()); }
public static function fromArray(array $arr) { $collection = new Queue(); foreach ($arr as $v) { if (is_array($v)) { $collection->enqueue(static::fromArray($v)); } else { $collection->enqueue($v); } } return $collection; }
/** * {@inheritDoc} */ public function execute($command) { $this->queue->enqueue($command); if (!$this->isDispatching) { $this->isDispatching = true; try { while (!$this->queue->isEmpty()) { $this->processCommand($this->queue->pop()); } } finally { $this->isDispatching = false; } } }
/** * {@inheritDoc} */ public function publish(DomainEventInterface $event) { $this->queue->enqueue($event); if (!$this->isPublishing && !$this->queue->isEmpty()) { $this->isPublishing = true; try { while (!$this->queue->isEmpty()) { $this->processEvent($this->queue->pop()); } } finally { $this->isPublishing = false; } } }