Code Duplication    Length = 18-20 lines in 2 locations

src/Api/StatKeywords.php 1 location

@@ 169-188 (lines=20) @@
166
            $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags']));
167
        }
168
169
        if (is_null($keyword['KeywordStats'])) {
170
            $modifiedKeyword->keyword_stats = null;
171
        } else {
172
            $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month) {
173
                return new StatLocalSearchTrend([
174
                    'month' => strtolower($month),
175
                    'search_volume' => ($searchVolume == '-') ? null : $searchVolume,
176
                ]);
177
            });
178
179
            $modifiedKeyword->keyword_stats = new StatKeywordStats([
180
                'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'],
181
                'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'],
182
                'regional_search_volume' => $keyword['KeywordStats']['RegionalSearchVolume'],
183
                'cpc' => $keyword['KeywordStats']['CPC'],
184
                'local_search_trends_by_month' => $localTrends->values(),
185
            ]);
186
        }
187
188
        if (is_null($keyword['KeywordRanking'])) {
189
            $modifiedKeyword->keyword_ranking = null;
190
        } else {
191
            $modifiedKeyword->keyword_ranking = new StatKeywordRanking([

src/Api/StatBulk.php 1 location

@@ 208-225 (lines=18) @@
205
            $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags']));
206
        }
207
208
        if (is_null($keyword['KeywordStats'])) {
209
            $modifiedKeyword->keyword_stats = null;
210
        } else {
211
            $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month) {
212
                return new StatLocalSearchTrend([
213
                    'month' => strtolower($month),
214
                    'search_volume' => ($searchVolume == '-') ? null : $searchVolume,
215
                ]);
216
            });
217
218
            $modifiedKeyword->keyword_stats = new StatKeywordStats([
219
                'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'],
220
                'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'],
221
                'targeted_search_volume' => $keyword['KeywordStats']['TargetedSearchVolume'],
222
                'cpc' => $keyword['KeywordStats']['CPC'],
223
                'local_search_trends_by_month' => $localTrends->values(),
224
            ]);
225
        }
226
227
        $modifiedKeyword->created_at = $keyword['CreatedAt'];
228