Code Duplication    Length = 34-34 lines in 2 locations

src/Api/StatSites.php 1 location

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

src/Api/StatTags.php 1 location

@@ 86-119 (lines=34) @@
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
102
        $sovSites->transform(function ($sov) {
103
104
            $shareOfVoice = new StatShareOfVoice([
105
                'date' => $sov['date'],
106
                'sites' => collect($sov['Site'])->transform(function ($site) {
107
                    return new StatShareOfVoiceSite([
108
                        'domain' => $site['Domain'],
109
                        'share' => (float) $site['Share'],
110
                        'pinned' => filter_var(array_get($site, 'Pinned'), FILTER_VALIDATE_BOOLEAN),
111
                    ]);
112
                }),
113
            ]);
114
115
            return $shareOfVoice;
116
        });
117
118
        return $sovSites;
119
    }
120
121
    /**
122
     * @param $tagID