(new AnalyticsData\BatchRunReportsRequest())->setRequests([
(new AnalyticsData\RunReportRequest())
->setDimensions([
new AnalyticsData\Dimension(['name' => 'year']),
new AnalyticsData\Dimension(['name' => 'month']),
new AnalyticsData\Dimension(['name' => 'medium']),
])
->setDimensionFilter(...)
])
But without chaining, it becomes
$request1 = new AnalyticsData\RunReportRequest();
$request1->setDimensions([
new AnalyticsData\Dimension(['name' => 'year']),
new AnalyticsData\Dimension(['name' => 'month']),
new AnalyticsData\Dimension(['name' => 'medium']),
]);
$request1->setDimensionFilter(...);
$batch = new AnalyticsData\BatchRunReportsRequest();
$batch->setRequests([$request1]);
Pretty much all the setters in the AnalyticsData lib return
void
, it would be much nicer to return$this
in all setters to be able to chain themExample: https://github.com/googleapis/google-api-php-client-services/blob/main/src/AnalyticsData/RunReportRequest.php
I wanted to write my requests like this
But without chaining, it becomes