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]']];
 }
Exemplo n.º 2
0
 public static function fromArray(array $arr)
 {
     $collection = new Stack();
     foreach ($arr as $v) {
         if (is_array($v)) {
             $collection->push(static::fromArray($v));
         } else {
             $collection->push($v);
         }
     }
     return $collection;
 }
Exemplo n.º 3
0
 public function testEnqueueAndDequeueToArray()
 {
     $this->coll->push('testing1');
     $this->coll->push('testing2');
     $this->coll->push('testing3');
     $this->coll->pop();
     $this->assertEquals(array('testing1', 'testing2'), $this->coll->toArray());
 }