@@ -3,8 +3,6 @@ |
||
3 | 3 | namespace SchulzeFelix\Stat\Api; |
4 | 4 | |
5 | 5 | use Carbon\Carbon; |
6 | -use Illuminate\Support\Collection; |
|
7 | -use Illuminate\Support\Facades\Cache; |
|
8 | 6 | use SchulzeFelix\Stat\Exceptions\ApiException; |
9 | 7 | use SchulzeFelix\Stat\Objects\StatBulkJob; |
10 | 8 | use SchulzeFelix\Stat\Objects\StatKeyword; |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | |
26 | 26 | $bulkJobs = collect(); |
27 | 27 | |
28 | - if($response['resultsreturned'] == 0) { |
|
28 | + if ($response['resultsreturned'] == 0) { |
|
29 | 29 | return $bulkJobs; |
30 | 30 | } |
31 | 31 | |
32 | - if($response['resultsreturned'] == 1) { |
|
32 | + if ($response['resultsreturned'] == 1) { |
|
33 | 33 | $bulkJobs->push($response['Result']); |
34 | 34 | } |
35 | 35 | |
36 | - if($response['resultsreturned'] > 1) { |
|
36 | + if ($response['resultsreturned'] > 1) { |
|
37 | 37 | $bulkJobs = collect($response['Result']); |
38 | 38 | } |
39 | 39 | |
40 | - return $bulkJobs->transform(function ($job, $key) { |
|
40 | + return $bulkJobs->transform(function($job, $key) { |
|
41 | 41 | |
42 | 42 | return new StatBulkJob([ |
43 | 43 | 'id' => $job['Id'], |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param bool $crawledKeywordsOnly This parameter causes the API to only include output for keywords that were crawled on the date parameter provided. |
65 | 65 | * @return int |
66 | 66 | */ |
67 | - public function ranks(Carbon $date, array $sites = null, $rankType = 'highest', $engines = null, bool $currentlyTrackedOnly = false , bool $crawledKeywordsOnly = false) |
|
67 | + public function ranks(Carbon $date, array $sites = null, $rankType = 'highest', $engines = null, bool $currentlyTrackedOnly = false, bool $crawledKeywordsOnly = false) |
|
68 | 68 | { |
69 | 69 | $this->validateBulkDate($date); |
70 | 70 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | $arguments['currently_tracked_only'] = $currentlyTrackedOnly; |
74 | 74 | $arguments['crawled_keywords_only'] = $crawledKeywordsOnly; |
75 | 75 | |
76 | - if( ! is_null($sites) && count($sites) > 0){ |
|
77 | - $arguments['site_id'] = implode(',', $sites);; |
|
76 | + if (!is_null($sites) && count($sites) > 0) { |
|
77 | + $arguments['site_id'] = implode(',', $sites); ; |
|
78 | 78 | } |
79 | - if( ! is_null($engines) && count($engines) > 0){ |
|
79 | + if (!is_null($engines) && count($engines) > 0) { |
|
80 | 80 | $arguments['engines'] = implode(',', $engines); |
81 | 81 | } |
82 | 82 | $response = $this->performQuery('bulk/ranks', $arguments); |
83 | 83 | |
84 | - return (int) $response['Result']['Id']; |
|
84 | + return (int)$response['Result']['Id']; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function status($bulkJobID) |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | $jobStatus->date = $response['Result']['Date']; |
96 | 96 | |
97 | 97 | $jobStatus->sites = collect(); |
98 | - if(isset($response['Result']['SiteId'])){ |
|
99 | - $jobStatus->sites = collect( explode(',', $response['Result']['SiteId'])) |
|
100 | - ->transform(function ($site, $key) { |
|
98 | + if (isset($response['Result']['SiteId'])) { |
|
99 | + $jobStatus->sites = collect(explode(',', $response['Result']['SiteId'])) |
|
100 | + ->transform(function($site, $key) { |
|
101 | 101 | return (int)$site; |
102 | 102 | }); |
103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $response = $this->performQuery('bulk/delete', ['id' => $bulkJobID]); |
118 | 118 | |
119 | - return (int) $response['Result']['Id']; |
|
119 | + return (int)$response['Result']['Id']; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function siteRankingDistributions($date) |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->validateBulkDate($date); |
125 | 125 | |
126 | 126 | $response = $this->performQuery('bulk/site_ranking_distributions', ['date' => $date->toDateString()]); |
127 | - return (int) $response['Result']['Id']; |
|
127 | + return (int)$response['Result']['Id']; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function tagRankingDistributions($date) |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | $this->validateBulkDate($date); |
133 | 133 | |
134 | 134 | $response = $this->performQuery('bulk/tag_ranking_distributions', ['date' => $date->toDateString()]); |
135 | - return (int) $response['Result']['Id']; |
|
135 | + return (int)$response['Result']['Id']; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | public function get($bulkJobID) |
139 | 139 | { |
140 | 140 | $bulkStatus = $this->status($bulkJobID); |
141 | 141 | |
142 | - if($bulkStatus['status'] != 'Completed') { |
|
142 | + if ($bulkStatus['status'] != 'Completed') { |
|
143 | 143 | throw ApiException::resultError('Bulk Job is not completed. Current status: ' . $bulkJobID['status'] . '.'); |
144 | 144 | } |
145 | 145 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | { |
165 | 165 | $projects = $this->getCollection($bulkStream['Project']); |
166 | 166 | |
167 | - $projects->transform(function ($project, $key) { |
|
167 | + $projects->transform(function($project, $key) { |
|
168 | 168 | return $this->transformProject($project); |
169 | 169 | }); |
170 | 170 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | $transformedProject->total_sites = $project['TotalSites']; |
180 | 180 | $transformedProject->created_at = $project['CreatedAt']; |
181 | 181 | |
182 | - if( $project['TotalSites'] == 0) { |
|
182 | + if ($project['TotalSites'] == 0) { |
|
183 | 183 | $transformedProject->sites = collect(); |
184 | 184 | } |
185 | - if( $project['TotalSites'] == 1) { |
|
185 | + if ($project['TotalSites'] == 1) { |
|
186 | 186 | $transformedProject->sites = collect([$project['Site']]); |
187 | 187 | } |
188 | - if( $project['TotalSites'] > 1) { |
|
188 | + if ($project['TotalSites'] > 1) { |
|
189 | 189 | $transformedProject->sites = collect($project['Site']); |
190 | 190 | } |
191 | - $transformedProject->sites->transform(function ($site, $key) { |
|
191 | + $transformedProject->sites->transform(function($site, $key) { |
|
192 | 192 | return $this->transformSite($site); |
193 | 193 | }); |
194 | 194 | |
@@ -204,19 +204,19 @@ discard block |
||
204 | 204 | $transformedSite->total_keywords = $site['TotalKeywords']; |
205 | 205 | $transformedSite->created_at = $site['CreatedAt']; |
206 | 206 | |
207 | - if(array_key_exists('Keyword', $site)){ |
|
207 | + if (array_key_exists('Keyword', $site)) { |
|
208 | 208 | |
209 | - $transformedSite->keywords = collect($site['Keyword'])->transform(function ($keyword, $key) { |
|
209 | + $transformedSite->keywords = collect($site['Keyword'])->transform(function($keyword, $key) { |
|
210 | 210 | return $this->transformKeyword($keyword); |
211 | 211 | }); |
212 | 212 | } |
213 | 213 | |
214 | - if(array_key_exists('RankDistribution', $site)){ |
|
214 | + if (array_key_exists('RankDistribution', $site)) { |
|
215 | 215 | $transformedSite->rank_distribution = $this->transformRankDistribution($site['RankDistribution']); |
216 | 216 | } |
217 | 217 | |
218 | - if(array_key_exists('Tag', $site)){ |
|
219 | - $transformedSite->tags = $this->getCollection($site['Tag'])->transform(function ($tag, $key) { |
|
218 | + if (array_key_exists('Tag', $site)) { |
|
219 | + $transformedSite->tags = $this->getCollection($site['Tag'])->transform(function($tag, $key) { |
|
220 | 220 | return $this->transformTag($tag); |
221 | 221 | }); |
222 | 222 | } |
@@ -235,16 +235,16 @@ discard block |
||
235 | 235 | $modifiedKeyword->keyword_device = $keyword['KeywordDevice']; |
236 | 236 | $modifiedKeyword->keyword_categories = $keyword['KeywordCategories']; |
237 | 237 | |
238 | - if(is_null($keyword['KeywordTags'])) { |
|
238 | + if (is_null($keyword['KeywordTags'])) { |
|
239 | 239 | $modifiedKeyword->keyword_tags = collect(); |
240 | 240 | } else { |
241 | 241 | $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags'])); |
242 | 242 | } |
243 | 243 | |
244 | - if( is_null($keyword['KeywordStats']) ) { |
|
244 | + if (is_null($keyword['KeywordStats'])) { |
|
245 | 245 | $modifiedKeyword->keyword_stats = null; |
246 | 246 | } else { |
247 | - $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month){ |
|
247 | + $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function($searchVolume, $month) { |
|
248 | 248 | return new StatLocalSearchTrend([ |
249 | 249 | 'month' => strtolower($month), |
250 | 250 | 'search_volume' => ($searchVolume == '-') ? null : $searchVolume, |
@@ -267,15 +267,15 @@ discard block |
||
267 | 267 | 'type' => $keyword['Ranking']['type'] |
268 | 268 | ]); |
269 | 269 | |
270 | - if(array_key_exists('Google', $keyword['Ranking'])){ |
|
270 | + if (array_key_exists('Google', $keyword['Ranking'])) { |
|
271 | 271 | $modifiedKeyword->ranking->google = $this->analyzeRanking($keyword['Ranking']['Google'], $keyword['Ranking']['type']); |
272 | 272 | } |
273 | 273 | |
274 | - if(array_key_exists('Yahoo', $keyword['Ranking'])){ |
|
274 | + if (array_key_exists('Yahoo', $keyword['Ranking'])) { |
|
275 | 275 | $modifiedKeyword->ranking->yahoo = $this->analyzeRanking($keyword['Ranking']['Yahoo'], $keyword['Ranking']['type']); |
276 | 276 | } |
277 | 277 | |
278 | - if(array_key_exists('Bing', $keyword['Ranking'])){ |
|
278 | + if (array_key_exists('Bing', $keyword['Ranking'])) { |
|
279 | 279 | $modifiedKeyword->ranking->bing = $this->analyzeRanking($keyword['Ranking']['Bing'], $keyword['Ranking']['type']); |
280 | 280 | } |
281 | 281 | |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | |
285 | 285 | private function analyzeRanking($rankingForEngine, $rankingType) |
286 | 286 | { |
287 | - if($rankingType == 'highest') { |
|
287 | + if ($rankingType == 'highest') { |
|
288 | 288 | return $this->transformRanking($rankingForEngine); |
289 | 289 | } |
290 | 290 | |
291 | - if(is_null($rankingForEngine['Result'])){ |
|
291 | + if (is_null($rankingForEngine['Result'])) { |
|
292 | 292 | return null; |
293 | 293 | } |
294 | 294 | |
295 | 295 | $rankings = $this->getCollection($rankingForEngine['Result'], 'Rank'); |
296 | 296 | |
297 | - $rankings->transform(function($ranking, $key){ |
|
297 | + $rankings->transform(function($ranking, $key) { |
|
298 | 298 | return $this->transformRanking($ranking); |
299 | 299 | }); |
300 | 300 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | $transformedRanking = new StatKeywordEngineRanking(); |
308 | 308 | $transformedRanking->rank = $ranking['Rank']; |
309 | - if(array_key_exists('BaseRank', $ranking)){ |
|
309 | + if (array_key_exists('BaseRank', $ranking)) { |
|
310 | 310 | $transformedRanking->base_rank = $ranking['BaseRank']; |
311 | 311 | } |
312 | 312 | $transformedRanking->url = $ranking['Url']; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $modifiedTag->id = $tag['Id']; |
321 | 321 | $modifiedTag->tag = $tag['Tag']; |
322 | 322 | |
323 | - if(isset($tag['RankDistribution'])){ |
|
323 | + if (isset($tag['RankDistribution'])) { |
|
324 | 324 | $modifiedTag->rank_distribution = $this->transformRankDistribution($tag['RankDistribution']); |
325 | 325 | } else { |
326 | 326 | $modifiedTag->rank_distribution = null; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @param $keyword |
125 | - * @return mixed |
|
125 | + * @return StatKeyword |
|
126 | 126 | */ |
127 | 127 | protected function transformCreatedKeyword($keyword) { |
128 | 128 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | /** |
141 | 141 | * @param $keyword |
142 | - * @return mixed |
|
142 | + * @return StatKeyword |
|
143 | 143 | */ |
144 | 144 | protected function transformListedKeyword($keyword) { |
145 | 145 | $modifiedKeyword = new StatKeyword(); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace SchulzeFelix\Stat\Api; |
4 | 4 | |
5 | -use Carbon\Carbon; |
|
6 | 5 | use Illuminate\Support\Collection; |
7 | 6 | use SchulzeFelix\Stat\Objects\StatKeyword; |
8 | 7 | use SchulzeFelix\Stat\Objects\StatKeywordEngineRanking; |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | $keywords = collect(); |
23 | 23 | |
24 | 24 | do { |
25 | - $response = $this->performQuery('keywords/list', ['site_id' => $siteID, 'start' => $start, 'results' => 5000 ]); |
|
25 | + $response = $this->performQuery('keywords/list', ['site_id' => $siteID, 'start' => $start, 'results' => 5000]); |
|
26 | 26 | $start += 5000; |
27 | 27 | |
28 | - if($response['totalresults'] == 0) { |
|
28 | + if ($response['totalresults'] == 0) { |
|
29 | 29 | break; |
30 | 30 | } |
31 | 31 | |
32 | - if(isset($response['Result']['Id'])) { |
|
32 | + if (isset($response['Result']['Id'])) { |
|
33 | 33 | $keywords->push($response['Result']); |
34 | 34 | } |
35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } while ($response['resultsreturned'] < $response['totalresults']); |
43 | 43 | |
44 | 44 | |
45 | - $keywords = $keywords->transform(function ($keyword, $key) { |
|
45 | + $keywords = $keywords->transform(function($keyword, $key) { |
|
46 | 46 | return $this->transformListedKeyword($keyword); |
47 | 47 | }); |
48 | 48 | |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | $arguments['market'] = $market; |
66 | 66 | $arguments['device'] = $device; |
67 | 67 | $arguments['type'] = 'regular'; |
68 | - $arguments['keyword'] = implode(',', array_map(function ($el) { |
|
68 | + $arguments['keyword'] = implode(',', array_map(function($el) { |
|
69 | 69 | return str_replace(',', '\,', $el); |
70 | 70 | }, $keywords)); |
71 | 71 | |
72 | - if( ! is_null($tags) && count($tags) > 0) |
|
72 | + if (!is_null($tags) && count($tags) > 0) |
|
73 | 73 | $arguments['tag'] = implode(',', $tags); |
74 | 74 | |
75 | - if( ! is_null($location) && $location != '') |
|
75 | + if (!is_null($location) && $location != '') |
|
76 | 76 | $arguments['location'] = $location; |
77 | 77 | |
78 | 78 | $response = $this->performQuery('keywords/create', $arguments); |
79 | 79 | |
80 | 80 | $keywords = collect(); |
81 | 81 | |
82 | - if($response['resultsreturned'] == 0) { |
|
82 | + if ($response['resultsreturned'] == 0) { |
|
83 | 83 | return $keywords; |
84 | 84 | } |
85 | - if($response['resultsreturned'] == 1) { |
|
85 | + if ($response['resultsreturned'] == 1) { |
|
86 | 86 | $keywords->push($response['Result']); |
87 | 87 | } else { |
88 | 88 | $keywords = collect($response['Result']); |
89 | 89 | } |
90 | 90 | |
91 | - return $keywords->transform(function ($keyword, $key) { |
|
91 | + return $keywords->transform(function($keyword, $key) { |
|
92 | 92 | return $this->transformCreatedKeyword($keyword); |
93 | 93 | }); |
94 | 94 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function delete($id) |
102 | 102 | { |
103 | - if(!is_array($id)) { |
|
103 | + if (!is_array($id)) { |
|
104 | 104 | $id = [$id]; |
105 | 105 | } |
106 | 106 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | $response = $this->performQuery('keywords/delete', ['id' => $ids]); |
110 | 110 | |
111 | - if(isset($response['Result']['Id'])){ |
|
111 | + if (isset($response['Result']['Id'])) { |
|
112 | 112 | return collect($response['Result']['Id']); |
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - return collect($response['Result'])->transform(function ($keywordID, $key) { |
|
116 | + return collect($response['Result'])->transform(function($keywordID, $key) { |
|
117 | 117 | return $keywordID['Id']; |
118 | 118 | }); |
119 | 119 | |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | $modifiedKeyword->keyword_device = $keyword['KeywordDevice']; |
151 | 151 | |
152 | 152 | |
153 | - if($keyword['KeywordTags'] == 'none') { |
|
153 | + if ($keyword['KeywordTags'] == 'none') { |
|
154 | 154 | $modifiedKeyword->keyword_tags = collect(); |
155 | 155 | } else { |
156 | 156 | $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags'])); |
157 | 157 | } |
158 | 158 | |
159 | - if( is_null($keyword['KeywordStats']) ) { |
|
159 | + if (is_null($keyword['KeywordStats'])) { |
|
160 | 160 | $modifiedKeyword->keyword_stats = null; |
161 | 161 | } else { |
162 | 162 | |
163 | - $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month){ |
|
163 | + $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function($searchVolume, $month) { |
|
164 | 164 | return new StatLocalSearchTrend([ |
165 | 165 | 'month' => strtolower($month), |
166 | 166 | 'search_volume' => ($searchVolume == '-') ? null : $searchVolume, |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | } |
179 | 179 | |
180 | - if( is_null($keyword['KeywordRanking']) ) { |
|
180 | + if (is_null($keyword['KeywordRanking'])) { |
|
181 | 181 | $modifiedKeyword->keyword_ranking = null; |
182 | 182 | } else { |
183 | 183 |
@@ -69,11 +69,13 @@ |
||
69 | 69 | return str_replace(',', '\,', $el); |
70 | 70 | }, $keywords)); |
71 | 71 | |
72 | - if( ! is_null($tags) && count($tags) > 0) |
|
73 | - $arguments['tag'] = implode(',', $tags); |
|
72 | + if( ! is_null($tags) && count($tags) > 0) { |
|
73 | + $arguments['tag'] = implode(',', $tags); |
|
74 | + } |
|
74 | 75 | |
75 | - if( ! is_null($location) && $location != '') |
|
76 | - $arguments['location'] = $location; |
|
76 | + if( ! is_null($location) && $location != '') { |
|
77 | + $arguments['location'] = $location; |
|
78 | + } |
|
77 | 79 | |
78 | 80 | $response = $this->performQuery('keywords/create', $arguments); |
79 | 81 |
@@ -2,9 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace SchulzeFelix\Stat\Api; |
4 | 4 | |
5 | -use Carbon\Carbon; |
|
6 | 5 | use Illuminate\Support\Collection; |
7 | -use Illuminate\Support\Facades\Cache; |
|
8 | 6 | use SchulzeFelix\Stat\Objects\StatProject; |
9 | 7 | use SchulzeFelix\Stat\Stat; |
10 | 8 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | $response = $this->performQuery('projects/list'); |
20 | 20 | |
21 | - $projects = collect($response['Result'])->map(function ($project, $key) { |
|
21 | + $projects = collect($response['Result'])->map(function($project, $key) { |
|
22 | 22 | return new StatProject([ |
23 | 23 | 'id' => $project['Id'], |
24 | 24 | 'name' => $project['Name'], |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace SchulzeFelix\Stat\Api; |
4 | 4 | |
5 | -use Carbon\Carbon; |
|
6 | -use Carbon\CarbonInterval; |
|
7 | 5 | use Illuminate\Support\Collection; |
8 | 6 | use SchulzeFelix\Stat\Objects\StatSubAccount; |
9 | 7 |
@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | $subaccounts = collect(); |
21 | 21 | |
22 | - if( ! isset($response['User']) ){ |
|
22 | + if (!isset($response['User'])) { |
|
23 | 23 | return $subaccounts; |
24 | 24 | } |
25 | 25 | |
26 | - if(isset($response['User']['Id'])) { |
|
26 | + if (isset($response['User']['Id'])) { |
|
27 | 27 | $subaccounts->push($response['User']); |
28 | 28 | } else { |
29 | 29 | $subaccounts = collect($response['User']); |
30 | 30 | } |
31 | 31 | |
32 | - $subaccounts->transform(function ($item, $key) { |
|
32 | + $subaccounts->transform(function($item, $key) { |
|
33 | 33 | |
34 | 34 | return new StatSubAccount([ |
35 | 35 | 'id' => $item['Id'], |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | return collect(); |
22 | 22 | } |
23 | 23 | |
24 | - $tags = collect($response['Result'])->transform(function ($item, $key) { |
|
24 | + $tags = collect($response['Result'])->transform(function($item, $key) { |
|
25 | 25 | |
26 | - if($item['Keywords'] == 'none') { |
|
26 | + if ($item['Keywords'] == 'none') { |
|
27 | 27 | $item['Keywords'] = collect(); |
28 | 28 | } else { |
29 | 29 | $item['Keywords'] = collect($item['Keywords']['Id']); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $rankDistribution = collect([$response['RankDistribution']]); |
59 | 59 | } |
60 | 60 | |
61 | - $rankDistribution->transform(function ($distribution, $key) { |
|
61 | + $rankDistribution->transform(function($distribution, $key) { |
|
62 | 62 | return $this->transformRankDistribution($distribution); |
63 | 63 | }); |
64 | 64 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } while ($response['resultsreturned'] < $response['totalresults']); |
29 | 29 | |
30 | 30 | |
31 | - $sites->transform(function ($site, $key) { |
|
31 | + $sites->transform(function($site, $key) { |
|
32 | 32 | return new StatSite([ |
33 | 33 | 'id' => $site['Id'], |
34 | 34 | 'project_id' => $site['ProjectId'], |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $sites = collect($response['Result']); |
68 | 68 | } |
69 | 69 | |
70 | - $sites->transform(function ($site, $key) use($projectID) { |
|
70 | + $sites->transform(function($site, $key) use($projectID) { |
|
71 | 71 | return new StatSite([ |
72 | 72 | 'id' => $site['Id'], |
73 | 73 | 'project_id' => $projectID, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $rankDistribution = collect([$response['RankDistribution']]); |
104 | 104 | } |
105 | 105 | |
106 | - $rankDistribution->transform(function ($distribution, $key) { |
|
106 | + $rankDistribution->transform(function($distribution, $key) { |
|
107 | 107 | return $this->transformRankDistribution($distribution); |
108 | 108 | }); |
109 | 109 | |
@@ -163,6 +163,6 @@ discard block |
||
163 | 163 | { |
164 | 164 | $response = $this->performQuery('sites/delete', ['id' => $siteID]); |
165 | 165 | |
166 | - return (int) $response['Result']['Id']; |
|
166 | + return (int)$response['Result']['Id']; |
|
167 | 167 | } |
168 | 168 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $response = $this->statClient->performQuery($method, $parameters); |
39 | 39 | } |
40 | - catch(ClientException $e) |
|
40 | + catch (ClientException $e) |
|
41 | 41 | { |
42 | 42 | $xml = simplexml_load_string($e->getResponse()->getBody()->getContents()); |
43 | 43 | throw ApiException::requestException($xml->__toString()); |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | protected function checkMaximumDateRange(Carbon $fromDate, Carbon $toDate, $maxDays = 31) |
60 | 60 | { |
61 | 61 | |
62 | - if($fromDate->diffInDays($toDate) > $maxDays) { |
|
63 | - throw ApiException::resultError('The maximum date range between from_date and to_date is '.$maxDays.' days.'); |
|
62 | + if ($fromDate->diffInDays($toDate) > $maxDays) { |
|
63 | + throw ApiException::resultError('The maximum date range between from_date and to_date is ' . $maxDays . ' days.'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function getCollection($element, $identifier = 'Id') |
73 | 73 | { |
74 | - if(isset($element[$identifier])){ |
|
74 | + if (isset($element[$identifier])) { |
|
75 | 75 | $collection = collect([$element]); |
76 | 76 | } else { |
77 | 77 | $collection = collect($element); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $rankDistribution = new StatRankDistribution(); |
90 | 90 | $rankDistribution->date = $distribution['date']; |
91 | 91 | |
92 | - if(array_key_exists('Google', $distribution)){ |
|
92 | + if (array_key_exists('Google', $distribution)) { |
|
93 | 93 | $rankDistribution->google = new StatEngineRankDistribution([ |
94 | 94 | 'one' => $distribution['Google']['One'], |
95 | 95 | 'two' => $distribution['Google']['Two'], |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ]); |
107 | 107 | } |
108 | 108 | |
109 | - if(array_key_exists('GoogleBaseRank', $distribution)){ |
|
109 | + if (array_key_exists('GoogleBaseRank', $distribution)) { |
|
110 | 110 | $rankDistribution->google_base_rank = new StatEngineRankDistribution([ |
111 | 111 | 'one' => $distribution['GoogleBaseRank']['One'], |
112 | 112 | 'two' => $distribution['GoogleBaseRank']['Two'], |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ]); |
124 | 124 | } |
125 | 125 | |
126 | - if(array_key_exists('Yahoo', $distribution)){ |
|
126 | + if (array_key_exists('Yahoo', $distribution)) { |
|
127 | 127 | $rankDistribution->yahoo = new StatEngineRankDistribution([ |
128 | 128 | 'one' => $distribution['Yahoo']['One'], |
129 | 129 | 'two' => $distribution['Yahoo']['Two'], |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ]); |
141 | 141 | } |
142 | 142 | |
143 | - if(array_key_exists('Bing', $distribution)){ |
|
143 | + if (array_key_exists('Bing', $distribution)) { |
|
144 | 144 | $rankDistribution->bing = new StatEngineRankDistribution([ |
145 | 145 | 'one' => $distribution['Bing']['One'], |
146 | 146 | 'two' => $distribution['Bing']['Two'], |
@@ -36,8 +36,7 @@ |
||
36 | 36 | try |
37 | 37 | { |
38 | 38 | $response = $this->statClient->performQuery($method, $parameters); |
39 | - } |
|
40 | - catch(ClientException $e) |
|
39 | + } catch(ClientException $e) |
|
41 | 40 | { |
42 | 41 | $xml = simplexml_load_string($e->getResponse()->getBody()->getContents()); |
43 | 42 | throw ApiException::requestException($xml->__toString()); |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | $response = $this->performQuery('rankings/list', ['keyword_id' => $keywordID, 'from_date' => $fromDate->toDateString(), 'to_date' => $toDate->toDateString(), 'start' => 0]); |
22 | 22 | $start += 30; |
23 | 23 | |
24 | - if($response['totalresults'] == 0) { |
|
24 | + if ($response['totalresults'] == 0) { |
|
25 | 25 | break; |
26 | 26 | } |
27 | 27 | |
28 | - if($response['totalresults'] == 1) { |
|
28 | + if ($response['totalresults'] == 1) { |
|
29 | 29 | $rankings->push($response['Result']); |
30 | 30 | } |
31 | 31 | |
32 | - if($response['totalresults'] > 1) { |
|
32 | + if ($response['totalresults'] > 1) { |
|
33 | 33 | $rankings = $rankings->merge($response['Result']); |
34 | 34 | } |
35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } while ($response['resultsreturned'] < $response['totalresults']); |
42 | 42 | |
43 | 43 | |
44 | - $rankings = $rankings->transform(function ($ranking, $key) { |
|
44 | + $rankings = $rankings->transform(function($ranking, $key) { |
|
45 | 45 | |
46 | 46 | return new StatKeywordRanking([ |
47 | 47 | 'date' => $ranking['date'], |
@@ -19,7 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | $response = $this->performQuery('serps/show', ['keyword_id' => $keywordID, 'engine' => $engine, 'date' => $date->toDateString()]); |
21 | 21 | |
22 | - return collect($response['Result'])->transform(function ($ranking, $key) { |
|
22 | + return collect($response['Result'])->transform(function($ranking, $key) { |
|
23 | 23 | |
24 | 24 | return new StatSerpItem([ |
25 | 25 | 'result_type' => $ranking['ResultType'], |