/**
* Fetches datasets in the project.
*
* Example:
* ```
* $datasets = $bigQuery->datasets();
*
* foreach ($datasets as $dataset) {
* var_dump($dataset->id());
* }
* ```
*
* @see https://cloud.google.com/bigquery/docs/reference/v2/datasets/list Datasets list API documentation.
*
* @param array $options [optional] {
* Configuration options.
*
* @type bool $all Whether to list all datasets, including hidden ones.
* @type int $maxResults Maximum number of results to return.
* }
* @return \Generator<Google\Cloud\BigQuery\Dataset>
*/
public function datasets(array $options = [])
{
$options['pageToken'] = null;
do {
$response = $this->connection->listDatasets($options + ['projectId' => $this->projectId]);
if (!isset($response['datasets'])) {
return;
}
foreach ($response['datasets'] as $dataset) {
(yield new Dataset($this->connection, $dataset['datasetReference']['datasetId'], $this->projectId, $dataset));
}
$options['pageToken'] = isset($response['nextPageToken']) ? $response['nextPageToken'] : null;
} while ($options['pageToken']);
}