AnalyticsUpdateTask::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
class AnalyticsUpdateTask extends BuildTask
0 ignored issues
show
Bug introduced by
The type BuildTask was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
{
5
    /**
6
     * @return string Title
7
     */
8
    public function getTitle()
9
    {
10
        return 'Update Google Analytics information for the configured pages';
11
    }
12
13
    /**
14
     * Start booting up
15
     * @param SS_HTTPRequest $request
0 ignored issues
show
Bug introduced by
The type SS_HTTPRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
     * @throws \Google_Exception
17
     * @throws \LogicException
18
     */
19
    public function run($request)
20
    {
21
        $clientService = new GoogleClientService();
22
23
        $this->getReport($clientService);
24
    }
25
26
    /**
27
     * Get the report and ask the service to update neatly
28
     *
29
     * @param GoogleClientService $client
30
     * @throws \ValidationException
31
     */
32
    protected function getReport($client)
33
    {
34
        $service = new GoogleAnalyticsReportService($client);
35
36
        $reports = $service->getReport();
37
        $count = 0;
38
39
        $updateService = new PageUpdateService();
40
        /** @var array $rows */
41
        foreach ($reports as $report) {
42
            /** @var array $rows */
43
            $rows = $report->getData()->getRows();
44
            $count += $updateService->updateVisits($rows);
45
        }
46
        echo "<p>$count Pages updated with Google Analytics visit count</p>";
47
    }
48
}
49