/**
* Fetches all buckets in the project.
*
* Example:
* ```
* $buckets = $storage->buckets();
* ```
*
* ```
* // Get all buckets beginning with the prefix 'album'.
* $buckets = $storage->buckets([
* 'prefix' => 'album'
* ]);
*
* foreach ($buckets as $bucket) {
* echo $bucket->name() . PHP_EOL;
* }
* ```
*
* @see https://cloud.google.com/storage/docs/json_api/v1/buckets/list Buckets list API documentation.
*
* @param array $options [optional] {
* Configuration options.
*
* @type integer $maxResults Maximum number of results to return per
* request.
* @type string $prefix Filter results with this prefix.
* @type string $projection Determines which properties to return. May
* be either 'full' or 'noAcl'.
* @type string $fields Selector which will cause the response to only
* return the specified fields.
* }
* @return \Generator<Google\Cloud\Storage\Bucket>
*/
public function buckets(array $options = [])
{
$options['pageToken'] = null;
do {
$response = $this->connection->listBuckets($options + ['project' => $this->projectId]);
foreach ($response['items'] as $bucket) {
(yield new Bucket($this->connection, $bucket['name'], $bucket));
}
$options['pageToken'] = isset($response['nextPageToken']) ? $response['nextPageToken'] : null;
} while ($options['pageToken']);
}