/** * Get a list of the topics registered to your project. * * Example: * ``` * $topics = $pubsub->topics(); * foreach ($topics as $topic) { * $info = $topic->info(); * echo $info['name']; // `projects/my-awesome-project/topics/<topic-name>` * } * ``` * * @see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list List Topics * * @param array $options [optional] { * Configuration Options * * @type int $pageSize Maximum number of results to return per * request. * } * @return Generator<Google\Cloud\PubSub\Topic> */ public function topics(array $options = []) { $options['pageToken'] = null; do { $response = $this->connection->listTopics($options + ['project' => $this->formatName('project', $this->projectId)]); foreach ($response['topics'] as $topic) { (yield $this->topicFactory($topic['name'], $topic)); } // If there's a page token, we'll request the next page. $options['pageToken'] = isset($response['nextPageToken']) ? $response['nextPageToken'] : null; } while ($options['pageToken']); }