diff --git a/app/library/App/Controllers/GaController.php b/app/library/App/Controllers/GaController.php index 75e5180..e053fff 100644 --- a/app/library/App/Controllers/GaController.php +++ b/app/library/App/Controllers/GaController.php @@ -58,6 +58,19 @@ class GaController extends CrudResourceController { } + /** + * Send request to Google Analytics Reporting API + * + * @param string $project_name + * @param string $view + * @param string $get_metrics + * @param string $get_dimensions + * @param string $start + * @param string $end + * @param bool $chart + * @param string $filter_expression + * @return array + */ public function sendGaRequest($project_name, $view, $get_metrics, $get_dimensions, $start, $end, $chart = false, $filter_expression = null) { putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); @@ -92,7 +105,7 @@ class GaController extends CrudResourceController { } } - //Create the ReportRequest object. + /** Create the ReportRequest object. **/ $request = new Google_Service_AnalyticsReporting_ReportRequest(); $request->setViewId($view); $request->setDateRanges($dateRange); @@ -110,7 +123,7 @@ class GaController extends CrudResourceController { $response = $analytics->reports->batchGet($body); - //have to rewrite code below (2 rows) + /** can be refactored (code below 2 rows) **/ $response = $response->toSimpleObject(); $response = $response->reports[0]['data']['rows']; @@ -124,6 +137,13 @@ class GaController extends CrudResourceController { } + /** + * Data-transformer for tables. Used by default. + * + * @param array $response + * @param string $project_name + * @return array + */ public static function responseDataTransform(array $response, $project_name) { $result = []; @@ -148,6 +168,13 @@ class GaController extends CrudResourceController { } + /** + * Data-transformer for charts, when query string contains "?chart=true" + * + * @param array $response + * @param string $project_name + * @return array + */ public static function responseChartTransform(array $response, $project_name) { $result = []; @@ -171,11 +198,9 @@ class GaController extends CrudResourceController { } - - - - - + /** + * without usage, from google docs. + */ public function printResults($reports) { $res = ''; for ( $reportIndex = 0; $reportIndex < count( $reports ); $reportIndex++ ) { -- libgit2 0.21.4