/**
  * @return array
  */
 public function pop()
 {
     $result = [];
     foreach ($this->shardList as $shardId) {
         $result[$shardId] = [];
     }
     array_map(function ($shardId) use(&$result) {
         $filePath = $this->getQueueFilePath($shardId);
         $fileQueue = new FileQueue($filePath);
         while (($data = $fileQueue->pop()) !== '') {
             $result[$shardId] = array_merge($result[$shardId], explode(PHP_EOL, $data));
         }
     }, $this->shardList);
     return $result;
 }
 public function testMulti()
 {
     $msgList = [];
     for ($i = 0; $i < 10; $i++) {
         $msgList[] = 'queue_item_' . $i;
     }
     $queue = new FileQueue($this->dir);
     foreach ($msgList as $msg) {
         $ret = $queue->push($msg);
         static::assertTrue($ret);
     }
     $offset = 0;
     while ($msg = $queue->pop()) {
         static::assertEquals($msgList[$offset], $msg);
         $offset++;
     }
 }
 /**
  * @return \Generator
  */
 public function get()
 {
     while (true) {
         $paramInJson = $this->queue->pop();
         if ($paramInJson === '') {
             if ($this->hasTask()) {
                 (yield $this->tasks);
                 $this->clearTask();
             }
             sleep(1);
             continue;
         }
         $this->addTask($paramInJson);
         if ($this->isTaskFull()) {
             (yield $this->tasks);
             $this->clearTask();
         }
     }
 }