Code Duplication    Length = 32-32 lines in 2 locations

src/Api/StatSites.php 1 location

@@ 202-233 (lines=32) @@
199
     * @param Carbon $toDate
200
     * @return Collection
201
     */
202
    public function sov($siteID, Carbon $fromDate, Carbon $toDate): Collection
203
    {
204
        $start = 0;
205
        $sovSites = collect();
206
207
        do {
208
            $response = $this->performQuery('sites/sov', ['id' => $siteID, 'from_date' => $fromDate->toDateString(), 'to_date' => $toDate->toDateString(), 'start' => $start, 'results' => 5000]);
209
            $start += 5000;
210
            $sovSites = $sovSites->merge($response['ShareOfVoice']);
211
212
            if (! isset($response['nextpage'])) {
213
                break;
214
            }
215
        } while ($response['resultsreturned'] < $response['totalresults']);
216
217
        $sovSites->transform(function ($sov) {
218
            $shareOfVoice = new StatShareOfVoice([
219
                'date' => $sov['date'],
220
                'sites' => collect($sov['Site'])->transform(function ($site) {
221
                    return new StatShareOfVoiceSite([
222
                        'domain' => $site['Domain'],
223
                        'share' => (float) $site['Share'],
224
                        'pinned' => filter_var(Arr::get($site, 'Pinned'), FILTER_VALIDATE_BOOLEAN),
225
                    ]);
226
                }),
227
            ]);
228
229
            return $shareOfVoice;
230
        });
231
232
        return $sovSites;
233
    }
234
235
    /**
236
     * @param $siteID

src/Api/StatTags.php 1 location

@@ 86-117 (lines=32) @@
83
     * @param Carbon $toDate
84
     * @return Collection
85
     */
86
    public function sov($siteID, Carbon $fromDate, Carbon $toDate): Collection
87
    {
88
        $start = 0;
89
        $sovSites = collect();
90
91
        do {
92
            $response = $this->performQuery('tags/sov', ['id' => $siteID, 'from_date' => $fromDate->toDateString(), 'to_date' => $toDate->toDateString(), 'start' => $start, 'results' => 5000]);
93
            $start += 5000;
94
            $sovSites = $sovSites->merge($response['ShareOfVoice']);
95
96
            if (! isset($response['nextpage'])) {
97
                break;
98
            }
99
        } while ($response['resultsreturned'] < $response['totalresults']);
100
101
        $sovSites->transform(function ($sov) {
102
            $shareOfVoice = new StatShareOfVoice([
103
                'date' => $sov['date'],
104
                'sites' => collect($sov['Site'])->transform(function ($site) {
105
                    return new StatShareOfVoiceSite([
106
                        'domain' => $site['Domain'],
107
                        'share' => (float) $site['Share'],
108
                        'pinned' => filter_var(Arr::get($site, 'Pinned'), FILTER_VALIDATE_BOOLEAN),
109
                    ]);
110
                }),
111
            ]);
112
113
            return $shareOfVoice;
114
        });
115
116
        return $sovSites;
117
    }
118
119
    /**
120
     * @param $tagID