public function collectionProvider()
 {
     $data = [1, 2, 3, 4];
     $queue = new Queue();
     $queue->push(1);
     $stack = new Stack();
     $stack->push(1);
     return [[new Vector($data), '[1,2,3,4]'], [new Set($data), '[1,2,3,4]'], [new Map(['test' => 'test']), '{"test": "test"}'], [$queue, '[1]'], [$stack, '[1]']];
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /**
  * {@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;
         }
     }
 }
Esempio n. 4
0
 /**
  * {@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;
         }
     }
 }
Esempio n. 5
0
 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());
 }