Google\Cloud\PubSub\Topic::exists PHP 메소드

exists() 공개 메소드

Service errors will NOT bubble up from this method. It will always return a boolean value. If you want to check for errors, use {@see \Google\Cloud\PubSub\Topic::info()}. Example: if ($topic->exists()) { echo 'Topic exists'; }
public exists ( array $options = [] ) : boolean
$options array [optional] Configuration Options
리턴 boolean
    public function exists(array $options = [])
    {
        try {
            $this->info($options);
            return true;
        } catch (NotFoundException $e) {
            return false;
        }
    }

Usage Example

예제 #1
0
 public function testExistsReturnsFalse()
 {
     $this->connection->getTopic(Argument::withEntry('foo', 'bar'))->willThrow(new NotFoundException('uh oh'));
     $topic = new Topic($this->connection->reveal(), 'topic-name', 'project-name');
     $this->assertFalse($topic->exists(['foo' => 'bar']));
 }