diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..40698c3 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/composer.json b/composer.json index aecf3a9..99bb593 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index c7709b9..d0ac9aa 100644 --- a/composer.lock +++ b/composer.lock @@ -2303,16 +2303,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "7.0.10", + "version": "7.0.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" + "reference": "52f55786aa2e52c26cd9e2db20aff2981e0f7399" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/52f55786aa2e52c26cd9e2db20aff2981e0f7399", + "reference": "52f55786aa2e52c26cd9e2db20aff2981e0f7399", "shasum": "" }, "require": { @@ -2362,7 +2362,13 @@ "testing", "xunit" ], - "time": "2019-11-20T13:55:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-27T06:08:35+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2556,16 +2562,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.9", + "version": "8.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6" + "reference": "3123601e3b29339b20129acc3f989cfec3274566" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6", - "reference": "f5c8a5dd5e7e8d68d7562bfb48d47287d33937d6", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3123601e3b29339b20129acc3f989cfec3274566", + "reference": "3123601e3b29339b20129acc3f989cfec3274566", "shasum": "" }, "require": { @@ -2581,7 +2587,7 @@ "phar-io/version": "^2.0.1", "php": "^7.2", "phpspec/prophecy": "^1.10.3", - "phpunit/php-code-coverage": "^7.0.10", + "phpunit/php-code-coverage": "^7.0.12", "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.1.2", @@ -2645,7 +2651,7 @@ "type": "github" } ], - "time": "2020-11-10T12:51:38+00:00" + "time": "2020-11-27T12:46:45+00:00" }, { "name": "pimple/pimple", diff --git a/src/Extractors/GoogleAnalytics.php b/src/Extractors/GoogleAnalytics.php index 237836d..270af53 100644 --- a/src/Extractors/GoogleAnalytics.php +++ b/src/Extractors/GoogleAnalytics.php @@ -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']]; * ``` * @@ -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; @@ -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(); @@ -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); @@ -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); } diff --git a/src/Extractors/Helper.php b/src/Extractors/Request.php similarity index 99% rename from src/Extractors/Helper.php rename to src/Extractors/Request.php index 23f1ac4..b1ab885 100644 --- a/src/Extractors/Helper.php +++ b/src/Extractors/Request.php @@ -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;