Code Duplication    Length = 18-18 lines in 2 locations

src/Analytics.php 2 locations

@@ 100-117 (lines=18) @@
97
            });
98
    }
99
100
    public function fetchTopReferrers(Period $period, int $maxResults = 20): Collection
101
    {
102
        $response = $this->performQuery($period,
103
            'ga:pageviews',
104
            [
105
                'dimensions' => 'ga:fullReferrer',
106
                'sort' => '-ga:pageviews',
107
                'max-results' => $maxResults,
108
            ]
109
        );
110
111
        return collect($response['rows'] ?? [])->map(function (array $pageRow) {
112
            return [
113
                'url' => $pageRow[0],
114
                'pageViews' => (int) $pageRow[1],
115
            ];
116
        });
117
    }
118
119
    public function fetchUserTypes(Period $period): Collection
120
    {
@@ 173-190 (lines=18) @@
170
    }
171
    
172
    // Function to get Visitors Device
173
    public function fetchDeviceVisitors(Period $period, int $maxResults = 10): Collection
174
    {
175
        $response = $this->performQuery(
176
            $period,
177
            'ga:users',
178
            [
179
                'dimensions' => 'ga:deviceCategory',
180
                'sort' => '-ga:deviceCategory',
181
            ]
182
        );
183
184
        return collect($response->rows ?? [])->map(function (array $userRow) {
185
            return [
186
                'device' => $userRow[0],
187
                'sessions' => (int) $userRow[1],
188
            ];
189
        });
190
    }
191
192
    /**
193
     * Call the query method on the authenticated client.