Code Duplication    Length = 18-20 lines in 2 locations

src/Api/StatBulk.php 1 location

@@ 244-261 (lines=18) @@
241
            $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags']));
242
        }
243
244
        if( is_null($keyword['KeywordStats']) ) {
245
            $modifiedKeyword->keyword_stats = null;
246
        } else {
247
            $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month){
248
                return new StatLocalSearchTrend([
249
                    'month' => strtolower($month),
250
                    'search_volume' => ($searchVolume == '-') ? null : $searchVolume,
251
                ]);
252
            });
253
254
            $modifiedKeyword->keyword_stats = new StatKeywordStats([
255
                'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'],
256
                'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'],
257
                'targeted_search_volume' => $keyword['KeywordStats']['TargetedSearchVolume'],
258
                'cpc' => $keyword['KeywordStats']['CPC'],
259
                'local_search_trends_by_month' => $localTrends->values(),
260
            ]);
261
        }
262
263
        $modifiedKeyword->created_at = $keyword['CreatedAt'];
264

src/Api/StatKeywords.php 1 location

@@ 159-178 (lines=20) @@
156
            $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags']));
157
        }
158
159
        if( is_null($keyword['KeywordStats']) ) {
160
            $modifiedKeyword->keyword_stats = null;
161
        } else {
162
163
            $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month){
164
                return new StatLocalSearchTrend([
165
                    'month' => strtolower($month),
166
                    'search_volume' => ($searchVolume == '-') ? null : $searchVolume,
167
                ]);
168
            });
169
170
            $modifiedKeyword->keyword_stats = new StatKeywordStats([
171
                'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'],
172
                'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'],
173
                'regional_search_volume' => $keyword['KeywordStats']['RegionalSearchVolume'],
174
                'cpc' => $keyword['KeywordStats']['CPC'],
175
                'local_search_trends_by_month' => $localTrends->values(),
176
            ]);
177
178
        }
179
180
        if( is_null($keyword['KeywordRanking']) ) {
181
            $modifiedKeyword->keyword_ranking = null;