@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | $category = $this->extractCategory($scriptDataInfo[0][12][13][0]); |
64 | 64 | $summary = $this->extractSummary($scriptDataInfo); |
65 | 65 | $installs = $scriptDataInfo[0][12][9][2] ?? 0; |
66 | - $score = (float)($scriptDataRating[0][6][0][1] ?? 0); |
|
67 | - $numberVoters = (int)($scriptDataRating[0][6][2][1] ?? 0); |
|
68 | - $numberReviews = (int)($scriptDataRating[0][6][3][1] ?? 0); |
|
66 | + $score = (float) ($scriptDataRating[0][6][0][1] ?? 0); |
|
67 | + $numberVoters = (int) ($scriptDataRating[0][6][2][1] ?? 0); |
|
68 | + $numberReviews = (int) ($scriptDataRating[0][6][3][1] ?? 0); |
|
69 | 69 | $histogramRating = $this->extractHistogramRating($scriptDataRating); |
70 | 70 | $price = $this->extractPrice($scriptDataPrice); |
71 | 71 | $currency = $scriptDataPrice[0][2][0][0][0][1][0][1]; |
72 | 72 | $priceText = $scriptDataPrice[0][2][0][0][0][1][0][2] ?: null; |
73 | 73 | $offersIAPCost = $scriptDataInfo[0][12][12][0] ?? null; |
74 | - $containsAds = (bool)$scriptDataInfo[0][12][14][0]; |
|
74 | + $containsAds = (bool) $scriptDataInfo[0][12][14][0]; |
|
75 | 75 | |
76 | 76 | [$size, $appVersion, $androidVersion] = $scriptDataVersion; |
77 | 77 | if (LocaleHelper::isDependOnDevice($locale, $size)) { |
@@ -201,8 +201,7 @@ discard block |
||
201 | 201 | LocaleHelper::findPreferredLanguage( |
202 | 202 | $locale, |
203 | 203 | $scriptDataInfo[0][19][1] |
204 | - ) : |
|
205 | - null; |
|
204 | + ) : null; |
|
206 | 205 | } |
207 | 206 | |
208 | 207 | /** |
@@ -235,7 +234,7 @@ discard block |
||
235 | 234 | */ |
236 | 235 | private function extractDeveloper(array $scriptDataInfo): Developer |
237 | 236 | { |
238 | - $developerPage = GPlayApps::GOOGLE_PLAY_URL . $scriptDataInfo[0][12][5][5][4][2]; |
|
237 | + $developerPage = GPlayApps::GOOGLE_PLAY_URL.$scriptDataInfo[0][12][5][5][4][2]; |
|
239 | 238 | $developerId = parse_query(parse_url($developerPage, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
240 | 239 | $developerName = $scriptDataInfo[0][12][5][1]; |
241 | 240 | $developerEmail = $scriptDataInfo[0][12][5][2][0]; |
@@ -261,8 +260,8 @@ discard block |
||
261 | 260 | private function extractCategory(array $data): ?Category |
262 | 261 | { |
263 | 262 | if (isset($data[0]) && $data[0] !== null && $data[2] !== null) { |
264 | - $genreId = (string)$data[2]; |
|
265 | - $genreName = (string)$data[0]; |
|
263 | + $genreId = (string) $data[2]; |
|
264 | + $genreName = (string) $data[0]; |
|
266 | 265 | return new Category($genreId, $genreName); |
267 | 266 | } |
268 | 267 | return null; |
@@ -290,8 +289,7 @@ discard block |
||
290 | 289 | protected function extractPrice(array $scriptDataPrice): ?float |
291 | 290 | { |
292 | 291 | return isset($scriptDataPrice[0][2][0][0][0][1][0][0]) ? |
293 | - (float)($scriptDataPrice[0][2][0][0][0][1][0][0] / 1000000) : |
|
294 | - 0.0; |
|
292 | + (float) ($scriptDataPrice[0][2][0][0][0][1][0][0] / 1000000) : 0.0; |
|
295 | 293 | } |
296 | 294 | |
297 | 295 | /** |
@@ -322,7 +320,7 @@ discard block |
||
322 | 320 | */ |
323 | 321 | private function extractScreenshots(array $scriptDataInfo): array |
324 | 322 | { |
325 | - return !empty($scriptDataInfo[0][12][0]) ? array_map(static function (array $v) { |
|
323 | + return !empty($scriptDataInfo[0][12][0]) ? array_map(static function(array $v) { |
|
326 | 324 | return new GoogleImage($v[3][2]); |
327 | 325 | }, $scriptDataInfo[0][12][0]) : []; |
328 | 326 | } |
@@ -338,8 +336,8 @@ discard block |
||
338 | 336 | $scriptDataInfo[0][12][3][0][3][2] !== null && |
339 | 337 | $scriptDataInfo[0][12][3][1][3][2] !== null |
340 | 338 | ) { |
341 | - $videoThumb = (string)$scriptDataInfo[0][12][3][1][3][2]; |
|
342 | - $videoUrl = (string)$scriptDataInfo[0][12][3][0][3][2]; |
|
339 | + $videoThumb = (string) $scriptDataInfo[0][12][3][1][3][2]; |
|
340 | + $videoUrl = (string) $scriptDataInfo[0][12][3][0][3][2]; |
|
343 | 341 | |
344 | 342 | return new Video($videoThumb, $videoUrl); |
345 | 343 | } |
@@ -46,9 +46,9 @@ |
||
46 | 46 | $scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents()); |
47 | 47 | foreach ($scriptData as $key => $scriptValue) { |
48 | 48 | if (isset($scriptValue[1][1][0][0][3][4][2])) { |
49 | - return GPlayApps::GOOGLE_PLAY_URL . $scriptValue[1][1][0][0][3][4][2] . |
|
50 | - '&' . GPlayApps::REQ_PARAM_LOCALE . '=' . urlencode($this->appId->getLocale()) . |
|
51 | - '&' . GPlayApps::REQ_PARAM_COUNTRY . '=' . urlencode($this->appId->getCountry()); |
|
49 | + return GPlayApps::GOOGLE_PLAY_URL.$scriptValue[1][1][0][0][3][4][2]. |
|
50 | + '&'.GPlayApps::REQ_PARAM_LOCALE.'='.urlencode($this->appId->getLocale()). |
|
51 | + '&'.GPlayApps::REQ_PARAM_COUNTRY.'='.urlencode($this->appId->getCountry()); |
|
52 | 52 | break; |
53 | 53 | } |
54 | 54 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ->setUrl($request->getUri()->__toString()); |
136 | 136 | } |
137 | 137 | $developerName = trim($developerNode->textContent); |
138 | - $developerUrl = GPlayApps::GOOGLE_PLAY_URL . $developerNode->attributes->getNamedItem('href')->textContent; |
|
138 | + $developerUrl = GPlayApps::GOOGLE_PLAY_URL.$developerNode->attributes->getNamedItem('href')->textContent; |
|
139 | 139 | $developerId = parse_query(parse_url($developerUrl, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
140 | 140 | $developer = new Developer( |
141 | 141 | Developer::newBuilder() |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | $iconSrc = $iconNode->textContent; |
164 | 164 | if (strpos($iconSrc, '//') === 0) { |
165 | - $iconSrc = 'https:' . $iconSrc; |
|
165 | + $iconSrc = 'https:'.$iconSrc; |
|
166 | 166 | } |
167 | 167 | $icon = new GoogleImage($iconSrc); |
168 | 168 | $icon->reset(); |
@@ -30,12 +30,12 @@ |
||
30 | 30 | $reviews = []; |
31 | 31 | foreach ($data as $reviewData) { |
32 | 32 | $reviewId = $reviewData[0]; |
33 | - $reviewUrl = $requestApp->getUrl() . '&reviewId=' . urlencode($reviewId); |
|
33 | + $reviewUrl = $requestApp->getUrl().'&reviewId='.urlencode($reviewId); |
|
34 | 34 | $userName = $reviewData[1][0]; |
35 | 35 | $avatar = (new GoogleImage($reviewData[1][1][3][2]))->setSize(64); |
36 | 36 | $date = DateStringFormatter::unixTimeToDateTime($reviewData[5][0]); |
37 | 37 | $score = $reviewData[2] ?? 0; |
38 | - $text = (string)($reviewData[4] ?? ''); |
|
38 | + $text = (string) ($reviewData[4] ?? ''); |
|
39 | 39 | $likeCount = $reviewData[6]; |
40 | 40 | |
41 | 41 | $reply = self::extractReplyReview($reviewData); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | private static function extractDeveloper(array $data): Developer |
58 | 58 | { |
59 | 59 | $developerName = $data[4][0][0][0]; |
60 | - $developerPage = GPlayApps::GOOGLE_PLAY_URL . $data[4][0][0][1][4][2]; |
|
60 | + $developerPage = GPlayApps::GOOGLE_PLAY_URL.$data[4][0][0][1][4][2]; |
|
61 | 61 | $developerId = parse_query(parse_url($developerPage, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
62 | 62 | $developer = new Developer( |
63 | 63 | Developer::newBuilder() |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function __invoke(RequestInterface $request, ResponseInterface $response) |
21 | 21 | { |
22 | 22 | $json = \GuzzleHttp\json_decode($response->getBody()->getContents(), true); |
23 | - return array_map(static function (array $v) { |
|
23 | + return array_map(static function(array $v) { |
|
24 | 24 | return $v['s']; |
25 | 25 | }, $json); |
26 | 26 | } |
@@ -80,15 +80,15 @@ |
||
80 | 80 | $this->address = $builder->getAddress(); |
81 | 81 | |
82 | 82 | if (empty($this->id)) { |
83 | - throw new \InvalidArgumentException('Developer id cannot be null or empty. ' . |
|
83 | + throw new \InvalidArgumentException('Developer id cannot be null or empty. '. |
|
84 | 84 | 'Solution: $developerBuilder->setId(...);'); |
85 | 85 | } |
86 | 86 | if (empty($this->url)) { |
87 | - throw new \InvalidArgumentException('Developer url cannot be null or empty. ' . |
|
87 | + throw new \InvalidArgumentException('Developer url cannot be null or empty. '. |
|
88 | 88 | 'Solution: $developerBuilder->setUrl(...);'); |
89 | 89 | } |
90 | 90 | if (empty($this->name)) { |
91 | - throw new \InvalidArgumentException('Developer name cannot be null or empty. ' . |
|
91 | + throw new \InvalidArgumentException('Developer name cannot be null or empty. '. |
|
92 | 92 | 'Solution: $developerBuilder->setName(...);'); |
93 | 93 | } |
94 | 94 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | $parts = array_slice($parts, 0, 4); |
177 | 177 | $path = implode('/', $parts); |
178 | - $url = $httpComponents['scheme'] . '://' . $httpComponents['host'] . '/' . $path . '/'; |
|
178 | + $url = $httpComponents['scheme'].'://'.$httpComponents['host'].'/'.$path.'/'; |
|
179 | 179 | $this->variantOfUrlWithFileName = true; |
180 | 180 | } elseif (($pos = strpos($url, '=')) !== false) { |
181 | 181 | $paramString = substr($url, $pos + 1); |
@@ -202,19 +202,19 @@ discard block |
||
202 | 202 | $command = $param[0]; // 1 char |
203 | 203 | switch ($command) { |
204 | 204 | case self::PARAM_SIZE: |
205 | - $arg = (int)substr($param, 1); |
|
205 | + $arg = (int) substr($param, 1); |
|
206 | 206 | $this->setSize($arg); |
207 | 207 | break; |
208 | 208 | case self::PARAM_WIDTH: |
209 | - $arg = (int)substr($param, 1); |
|
209 | + $arg = (int) substr($param, 1); |
|
210 | 210 | $this->setWidth($arg); |
211 | 211 | break; |
212 | 212 | case self::PARAM_HEIGHT: |
213 | - $arg = (int)substr($param, 1); |
|
213 | + $arg = (int) substr($param, 1); |
|
214 | 214 | $this->setHeight($arg); |
215 | 215 | break; |
216 | 216 | case self::PARAM_BORDER: |
217 | - $arg = (int)substr($param, 1); |
|
217 | + $arg = (int) substr($param, 1); |
|
218 | 218 | $this->setBorder($arg); |
219 | 219 | break; |
220 | 220 | case self::PARAM_SQUARE_CROP: |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | { |
247 | 247 | $params = []; |
248 | 248 | if ($this->size !== null) { |
249 | - $params[] = self::PARAM_SIZE . $this->size; |
|
249 | + $params[] = self::PARAM_SIZE.$this->size; |
|
250 | 250 | } else { |
251 | 251 | if ($this->width !== null) { |
252 | - $params[] = self::PARAM_WIDTH . $this->width; |
|
252 | + $params[] = self::PARAM_WIDTH.$this->width; |
|
253 | 253 | } |
254 | 254 | if ($this->height !== null) { |
255 | - $params[] = self::PARAM_HEIGHT . $this->height; |
|
255 | + $params[] = self::PARAM_HEIGHT.$this->height; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | if (empty($params)) { |
267 | 267 | return $this->baseUrl; |
268 | 268 | } |
269 | - return $this->baseUrl . implode('-', $params) . '/'; |
|
269 | + return $this->baseUrl.implode('-', $params).'/'; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if ($this->border !== null) { |
273 | - $params[] = self::PARAM_BORDER . $this->border; |
|
273 | + $params[] = self::PARAM_BORDER.$this->border; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($this->verticalFlip) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | if (empty($params)) { |
285 | 285 | return $this->baseUrl; |
286 | 286 | } |
287 | - return $this->baseUrl . '=' . implode('-', $params); |
|
287 | + return $this->baseUrl.'='.implode('-', $params); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public function getOriginalSizeUrl(): string |
308 | 308 | { |
309 | - $params = [self::PARAM_SIZE . '0']; |
|
309 | + $params = [self::PARAM_SIZE.'0']; |
|
310 | 310 | if ($this->variantOfUrlWithFileName) { |
311 | - return $this->baseUrl . implode('-', $params) . '/'; |
|
311 | + return $this->baseUrl.implode('-', $params).'/'; |
|
312 | 312 | } |
313 | - return $this->baseUrl . '=' . implode('-', $params); |
|
313 | + return $this->baseUrl.'='.implode('-', $params); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | $hashLength = strlen($hash); |
330 | 330 | $parts = max(0, min(6, $parts)); |
331 | 331 | if ($parts > 0) { |
332 | - $partLength = max(1, min($partLength, (int)($hashLength / $parts))); |
|
332 | + $partLength = max(1, min($partLength, (int) ($hashLength / $parts))); |
|
333 | 333 | $partsBuild = []; |
334 | 334 | for ($i = 0; $i < $parts; $i++) { |
335 | 335 | $partsBuild[] = substr($hash, $i * $partLength, $partLength); |
336 | 336 | } |
337 | - $hash = implode('/', $partsBuild) . '/' . $hash; |
|
337 | + $hash = implode('/', $partsBuild).'/'.$hash; |
|
338 | 338 | } |
339 | 339 | return $hash; |
340 | 340 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | ]); |
588 | 588 | |
589 | 589 | return new ImageInfo($url, $destPath); |
590 | - } catch (\Throwable|GuzzleException $e) { |
|
590 | + } catch (\Throwable | GuzzleException $e) { |
|
591 | 591 | if (is_file($destPath)) { |
592 | 592 | unlink($destPath); |
593 | 593 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | RequestOptions::HTTP_ERRORS => true, |
627 | 627 | ]); |
628 | 628 | return $response->getBody()->getContents(); |
629 | - } catch (\Throwable|GuzzleException $e) { |
|
629 | + } catch (\Throwable | GuzzleException $e) { |
|
630 | 630 | $ge = new GooglePlayException($e->getMessage(), $e->getCode(), $e); |
631 | 631 | $ge->setUrl($url); |
632 | 632 | throw $ge; |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | if ($otherApp->getIcon()->getOriginalSizeUrl() !== $this->getIcon()->getOriginalSizeUrl()) { |
504 | 504 | return false; |
505 | 505 | } |
506 | - $diff = array_udiff($otherApp->screenshots, $this->screenshots, static function (GoogleImage $a, GoogleImage $b) { |
|
506 | + $diff = array_udiff($otherApp->screenshots, $this->screenshots, static function(GoogleImage $a, GoogleImage $b) { |
|
507 | 507 | return strcmp($a->getOriginalSizeUrl(), $b->getOriginalSizeUrl()); |
508 | 508 | }); |
509 | 509 | return empty($diff); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | $array['description'] = $this->description; |
521 | 521 | $array['translatedFromLocale'] = $this->translatedFromLocale; |
522 | 522 | $array['cover'] = $this->cover !== null ? $this->cover->getUrl() : null; |
523 | - $array['screenshots'] = array_map(static function (GoogleImage $googleImage) { |
|
523 | + $array['screenshots'] = array_map(static function(GoogleImage $googleImage) { |
|
524 | 524 | return $googleImage->getUrl(); |
525 | 525 | }, $this->screenshots); |
526 | 526 | $array['category'] = $this->category->asArray(); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $array['updated'] = $this->updated !== null ? $this->updated->format(\DateTimeInterface::RFC3339) : null; |
548 | 548 | $array['updatedTimestamp'] = $this->updated !== null ? $this->updated->getTimestamp() : 0; |
549 | 549 | $array['numberReviews'] = $this->numberReviews; |
550 | - $array['reviews'] = array_map(static function (Review $review) { |
|
550 | + $array['reviews'] = array_map(static function(Review $review) { |
|
551 | 551 | return $review->asArray(); |
552 | 552 | }, $this->reviews); |
553 | 553 | return $array; |