Phalcon\Queue\Beanstalk\Extended::getTubes PHP Method

getTubes() public method

Returns the names of all tubes on the server.
public getTubes ( ) : array
return array
    public function getTubes()
    {
        $result = [];
        $lines = $this->getResponseLines('list-tubes');
        if (null !== $lines) {
            foreach ($lines as $line) {
                $line = ltrim($line, '- ');
                if (empty($this->tubePrefix) || 0 === strpos($line, $this->tubePrefix)) {
                    $result[] = !empty($this->tubePrefix) ? substr($line, strlen($this->tubePrefix)) : $line;
                }
            }
        }
        return $result;
    }

Usage Example

Example #1
0
 /**
  * @depends testShouldPutAndReserve
  */
 public function testShouldGetTubes()
 {
     $tubes = $this->client->getTubes();
     $this->assertNotEmpty($tubes);
     $this->assertContains(self::TUBE_NAME, $tubes);
     // Cleanup tubes
     foreach ($tubes as $tube) {
         $isRunning = true;
         $this->client->watch($tube);
         do {
             $job = $this->client->reserve(0.1);
             if ($job) {
                 $this->assertTrue($job->delete());
             } else {
                 $isRunning = false;
             }
         } while ($isRunning);
     }
 }
All Usage Examples Of Phalcon\Queue\Beanstalk\Extended::getTubes