Predis\Connection\Aggregate\PredisCluster::isConnected PHP Method

isConnected() public method

public isConnected ( )
    public function isConnected()
    {
        foreach ($this->pool as $connection) {
            if ($connection->isConnected()) {
                return true;
            }
        }
        return false;
    }

Usage Example

コード例 #1
0
 /**
  * @group disconnected
  */
 public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed()
 {
     $connection1 = $this->getMockConnection();
     $connection1->expects($this->once())->method('isConnected')->will($this->returnValue(false));
     $connection2 = $this->getMockConnection();
     $connection2->expects($this->once())->method('isConnected')->will($this->returnValue(false));
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     $this->assertFalse($cluster->isConnected());
 }