Google\Cloud\Storage\Bucket::exists PHP Method

exists() public method

Example: if ($bucket->exists()) { echo 'Bucket exists!'; }
public exists ( ) : boolean
return boolean
    public function exists()
    {
        try {
            $this->connection->getBucket($this->identity + ['fields' => 'name']);
        } catch (NotFoundException $ex) {
            return false;
        }
        return true;
    }

Usage Example

 public function testDoesExistFalse()
 {
     $this->connection->getBucket(Argument::any())->willThrow(new NotFoundException(null));
     $bucket = new Bucket($this->connection->reveal(), 'bucket');
     $this->assertFalse($bucket->exists());
 }