Skip to content

Commit

Permalink
Add travis ci (#1)
Browse files Browse the repository at this point in the history
* Add Travis CI

Co-authored-by: Karl DeBisschop <karl.debisschop@bioraft.com>
  • Loading branch information
kdebisschop and Karl DeBisschop authored Nov 28, 2020
1 parent 0297768 commit d587efe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 23 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: php
php:
- 7.4
install:
- composer install
script:
- vendor/bin/php-cs-fixer --dry-run -v --allow-risky=yes fix
- vendor/bin/phpcs
- vendor/bin/phpstan --memory-limit=256M analyze
- vendor/bin/phpunit
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"scan": [
"php-cs-fixer --dry-run -v --allow-risky=yes fix",
"phpcs",
"(cd tests && phpcs)",
"phpstan --memory-limit=256M analyze"
],
"test": "phpunit",
Expand Down
28 changes: 17 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions src/Extractors/GoogleAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GoogleAnalytics extends Extractor
/**
* The dimension or dimensions used to group analytics data (frequently "ga:date").
*
* ```pho
* ```php
* $options = ['dimensions' => ['ga:date']];
* ```
*
Expand Down Expand Up @@ -146,7 +146,7 @@ class GoogleAnalytics extends Extractor

private \Google_Service_AnalyticsReporting $reportingService;

public \Google_Service_AnalyticsReporting_ReportRequest $reportRequest;
private \Google_Service_AnalyticsReporting_ReportRequest $reportRequest;

private int $clientReqCount = 0;

Expand All @@ -159,11 +159,11 @@ class GoogleAnalytics extends Extractor
* setters for analytics service and analytics reporting service must be
* used to inject the required dependencies.
*
* @param string|null $config The configuration json file
* @param string $config The configuration json file
*
* @throws GoogleException
*/
public function __construct(?string $config = '')
public function __construct(string $config = '')
{
if ('' !== $config && file_exists($config)) {
$client = new \Google_Client();
Expand Down Expand Up @@ -301,7 +301,10 @@ private function isWantedView(string $name): bool
return !isset($this->input) || 0 === count($this->views) || in_array($name, $this->views, true);
}

public function reportRequest(string $viewId): \Google_Service_AnalyticsReporting_GetReportsRequest
/**
* Creates GetReportsRequest object with current viewID and the shared request parameters set earlier.
*/
private function reportRequest(string $viewId): \Google_Service_AnalyticsReporting_GetReportsRequest
{
$this->reportRequest->setViewId($viewId);

Expand All @@ -311,14 +314,19 @@ public function reportRequest(string $viewId): \Google_Service_AnalyticsReportin
return $body;
}

public function reportRequestSetup(array $dimensions, array $metrics, string $start, string $end): void
/**
* Sets general parameters for report requests.
*
* Our requests only differ in having a different viewID, so we only need to set these once.
*/
private function reportRequestSetup(array $dimensions, array $metrics, string $start, string $end): void
{
$this->reportRequest = new \Google_Service_AnalyticsReporting_ReportRequest();
$this->reportRequest->setDateRanges(Helper::dateRange($start, $end));
$this->reportRequest->setDimensions(Helper::dimensions($dimensions));
$this->reportRequest->setDateRanges(Request::dateRange($start, $end));
$this->reportRequest->setDimensions(Request::dimensions($dimensions));
$this->reportRequest->setDimensionFilterClauses([]);
$this->reportRequest->setMetrics(Helper::metrics($metrics));
$this->reportRequest->setPageSize(Helper::REPORT_PAGE_SIZE);
$this->reportRequest->setMetrics(Request::metrics($metrics));
$this->reportRequest->setPageSize(Request::REPORT_PAGE_SIZE);
$this->reportRequest->setIncludeEmptyRows(true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Extractors/Helper.php → src/Extractors/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Provides some static methods that can be used to in Extractor code and in tests.
*/
class Helper
class Request
{
public const REPORT_PAGE_SIZE = 1000;

Expand Down

0 comments on commit d587efe

Please sign in to comment.