@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $scripts = []; |
24 | 24 | if (preg_match_all('/>AF_initDataCallback[\s\S]*?<\/script/', $html, $matches)) { |
25 | - $scripts = array_reduce($matches[0], static function ($carry, $item) { |
|
25 | + $scripts = array_reduce($matches[0], static function($carry, $item) { |
|
26 | 26 | if ( |
27 | 27 | preg_match("/(ds:.*?)'/", $item, $keyMatch) && |
28 | 28 | preg_match('/return ([\s\S]*?)}}\);<\//', $item, $valueMatch) |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | { |
44 | 44 | $doc = new \DOMDocument(); |
45 | 45 | $internalErrors = libxml_use_internal_errors(true); |
46 | - if (!$doc->loadHTML('<?xml encoding="utf-8"?>' . $html)) { |
|
46 | + if (!$doc->loadHTML('<?xml encoding="utf-8"?>'.$html)) { |
|
47 | 47 | throw new |
48 | - \RuntimeException('error load html: ' . $html); |
|
48 | + \RuntimeException('error load html: '.$html); |
|
49 | 49 | } |
50 | 50 | libxml_use_internal_errors($internalErrors); |
51 | 51 | return $doc; |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | case 'p': |
90 | 90 | case 'ul': |
91 | 91 | case 'div': |
92 | - $text = "\n\n" . $text . "\n\n"; |
|
92 | + $text = "\n\n".$text."\n\n"; |
|
93 | 93 | break; |
94 | 94 | case 'li': |
95 | - $text = '- ' . $text . "\n"; |
|
95 | + $text = '- '.$text."\n"; |
|
96 | 96 | break; |
97 | 97 | case 'br': |
98 | 98 | $text .= "\n"; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public const GOOGLE_PLAY_URL = 'https://play.google.com'; |
62 | 62 | |
63 | 63 | /** @var string Google Play apps url */ |
64 | - public const GOOGLE_PLAY_APPS_URL = self::GOOGLE_PLAY_URL . '/store/apps'; |
|
64 | + public const GOOGLE_PLAY_APPS_URL = self::GOOGLE_PLAY_URL.'/store/apps'; |
|
65 | 65 | |
66 | 66 | /** @var int Maximum number of search results (Google limit). */ |
67 | 67 | public const MAX_SEARCH_RESULTS = 250; |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | /** |
327 | 327 | * @var AppDetail[] $list |
328 | 328 | */ |
329 | - $list = array_filter($list, static function (AppDetail $app) { |
|
329 | + $list = array_filter($list, static function(AppDetail $app) { |
|
330 | 330 | return !$app->isAutoTranslatedDescription(); |
331 | 331 | }); |
332 | 332 | |
333 | 333 | $preferredApp = $list[$preferredLocale]; |
334 | - $list = array_filter($list, static function (AppDetail $app, string $locale) use ($preferredApp, $list) { |
|
334 | + $list = array_filter($list, static function(AppDetail $app, string $locale) use ($preferredApp, $list) { |
|
335 | 335 | // deletes locales in which there is no translation added, but automatic translation by Google Translate is used. |
336 | 336 | if ($preferredApp->getLocale() === $locale || !$preferredApp->equals($app)) { |
337 | 337 | if (($pos = strpos($locale, '_')) !== false) { |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | // sorting array keys; the first key is the preferred locale |
356 | 356 | uksort( |
357 | 357 | $list, |
358 | - static function ( |
|
358 | + static function( |
|
359 | 359 | /** @noinspection PhpUnusedParameterInspection */ |
360 | 360 | string $a, |
361 | 361 | string $b |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $appId = $this->castToAppId($appId); |
381 | 381 | |
382 | 382 | try { |
383 | - return (bool)$this->getHttpClient()->request( |
|
383 | + return (bool) $this->getHttpClient()->request( |
|
384 | 384 | 'HEAD', |
385 | 385 | $appId->getFullUrl(), |
386 | 386 | [ |
@@ -457,14 +457,12 @@ discard block |
||
457 | 457 | $allReviews = []; |
458 | 458 | |
459 | 459 | $cacheTtl = $sort === SortEnum::NEWEST() ? |
460 | - \DateInterval::createFromDateString('5 min') : |
|
461 | - \DateInterval::createFromDateString('1 hour'); |
|
460 | + \DateInterval::createFromDateString('5 min') : \DateInterval::createFromDateString('1 hour'); |
|
462 | 461 | |
463 | 462 | try { |
464 | 463 | do { |
465 | 464 | $count = $limit === self::UNLIMIT ? |
466 | - PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE : |
|
467 | - min(PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1)); |
|
465 | + PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE : min(PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1)); |
|
468 | 466 | |
469 | 467 | $request = PlayStoreUiRequest::getReviewsRequest($appId, $count, $sort, $token); |
470 | 468 | |
@@ -566,8 +564,7 @@ discard block |
||
566 | 564 | |
567 | 565 | while ($token !== null && ($limit === self::UNLIMIT || $allCount < $limit)) { |
568 | 566 | $count = $limit === self::UNLIMIT ? |
569 | - PlayStoreUiRequest::LIMIT_APPS_ON_PAGE : |
|
570 | - min(PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1)); |
|
567 | + PlayStoreUiRequest::LIMIT_APPS_ON_PAGE : min(PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1)); |
|
571 | 568 | |
572 | 569 | $request = PlayStoreUiRequest::getAppsRequest($locale, $country, $count, $token); |
573 | 570 | |
@@ -607,7 +604,7 @@ discard block |
||
607 | 604 | { |
608 | 605 | $appId = $this->castToAppId($appId); |
609 | 606 | |
610 | - $url = self::GOOGLE_PLAY_URL . '/store/xhr/getdoc?authuser=0'; |
|
607 | + $url = self::GOOGLE_PLAY_URL.'/store/xhr/getdoc?authuser=0'; |
|
611 | 608 | try { |
612 | 609 | return $this->getHttpClient()->request( |
613 | 610 | 'POST', |
@@ -674,7 +671,7 @@ discard block |
||
674 | 671 | $urls = []; |
675 | 672 | $url = self::GOOGLE_PLAY_APPS_URL; |
676 | 673 | foreach ($locales as $locale) { |
677 | - $urls[$locale] = $url . '?' . http_build_query([ |
|
674 | + $urls[$locale] = $url.'?'.http_build_query([ |
|
678 | 675 | self::REQ_PARAM_LOCALE => $locale, |
679 | 676 | ]); |
680 | 677 | } |
@@ -730,7 +727,7 @@ discard block |
||
730 | 727 | )); |
731 | 728 | } |
732 | 729 | |
733 | - $url = self::GOOGLE_PLAY_APPS_URL . '/dev'; |
|
730 | + $url = self::GOOGLE_PLAY_APPS_URL.'/dev'; |
|
734 | 731 | try { |
735 | 732 | return $this->getHttpClient()->request( |
736 | 733 | 'GET', |
@@ -761,7 +758,7 @@ discard block |
||
761 | 758 | return $developerId->getId(); |
762 | 759 | } |
763 | 760 | if (is_int($developerId)) { |
764 | - return (string)$developerId; |
|
761 | + return (string) $developerId; |
|
765 | 762 | } |
766 | 763 | return $developerId; |
767 | 764 | } |
@@ -799,9 +796,9 @@ discard block |
||
799 | 796 | } |
800 | 797 | |
801 | 798 | $urls = []; |
802 | - $url = self::GOOGLE_PLAY_APPS_URL . '/dev'; |
|
799 | + $url = self::GOOGLE_PLAY_APPS_URL.'/dev'; |
|
803 | 800 | foreach ($locales as $locale) { |
804 | - $urls[$locale] = $url . '?' . http_build_query([ |
|
801 | + $urls[$locale] = $url.'?'.http_build_query([ |
|
805 | 802 | self::REQ_PARAM_ID => $id, |
806 | 803 | self::REQ_PARAM_LOCALE => $locale, |
807 | 804 | ]); |
@@ -843,7 +840,7 @@ discard block |
||
843 | 840 | ]; |
844 | 841 | |
845 | 842 | if (is_numeric($developerId)) { |
846 | - $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/dev?' . http_build_query($query); |
|
843 | + $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/dev?'.http_build_query($query); |
|
847 | 844 | try { |
848 | 845 | /** |
849 | 846 | * @var string|null $developerUrl |
@@ -858,13 +855,13 @@ discard block |
||
858 | 855 | if ($developerUrl === null) { |
859 | 856 | return []; |
860 | 857 | } |
861 | - $developerUrl .= '&' . self::REQ_PARAM_LOCALE . '=' . urlencode($this->locale) . |
|
862 | - '&' . self::REQ_PARAM_COUNTRY . '=' . urlencode($this->country); |
|
858 | + $developerUrl .= '&'.self::REQ_PARAM_LOCALE.'='.urlencode($this->locale). |
|
859 | + '&'.self::REQ_PARAM_COUNTRY.'='.urlencode($this->country); |
|
863 | 860 | } catch (GuzzleException $e) { |
864 | 861 | throw new GooglePlayException($e->getMessage(), $e->getCode(), $e); |
865 | 862 | } |
866 | 863 | } else { |
867 | - $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/developer?' . http_build_query($query); |
|
864 | + $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/developer?'.http_build_query($query); |
|
868 | 865 | } |
869 | 866 | |
870 | 867 | return $this->getAppsFromClusterPage( |
@@ -945,7 +942,7 @@ discard block |
||
945 | 942 | 'gl' => $this->country, |
946 | 943 | 'price' => $price->value(), |
947 | 944 | ]; |
948 | - $clusterPageUrl = self::GOOGLE_PLAY_URL . '/store/search?' . http_build_query($params); |
|
945 | + $clusterPageUrl = self::GOOGLE_PLAY_URL.'/store/search?'.http_build_query($params); |
|
949 | 946 | |
950 | 947 | return $this->getAppsFromClusterPage($clusterPageUrl, $this->locale, $this->country, $limit); |
951 | 948 | } |
@@ -981,13 +978,13 @@ discard block |
||
981 | 978 | $maxResults = $maxOffset + $limitOnPage; |
982 | 979 | |
983 | 980 | $limit = $limit === self::UNLIMIT ? $maxResults : min($maxResults, max(1, $limit)); |
984 | - $collection = (string)$collection; |
|
981 | + $collection = (string) $collection; |
|
985 | 982 | |
986 | - $url = self::GOOGLE_PLAY_APPS_URL . ''; |
|
983 | + $url = self::GOOGLE_PLAY_APPS_URL.''; |
|
987 | 984 | if ($category !== null) { |
988 | - $url .= '/category/' . $this->castToCategoryId($category); |
|
985 | + $url .= '/category/'.$this->castToCategoryId($category); |
|
989 | 986 | } |
990 | - $url .= '/collection/' . $collection; |
|
987 | + $url .= '/collection/'.$collection; |
|
991 | 988 | |
992 | 989 | $offset = 0; |
993 | 990 | |
@@ -1049,7 +1046,7 @@ discard block |
||
1049 | 1046 | if ($category instanceof Category) { |
1050 | 1047 | return $category->getId(); |
1051 | 1048 | } |
1052 | - return (string)$category; |
|
1049 | + return (string) $category; |
|
1053 | 1050 | } |
1054 | 1051 | |
1055 | 1052 | /** |
@@ -1076,14 +1073,14 @@ discard block |
||
1076 | 1073 | $mapping = []; |
1077 | 1074 | foreach ($images as $image) { |
1078 | 1075 | if (!$image instanceof GoogleImage) { |
1079 | - throw new \InvalidArgumentException('An array of ' . GoogleImage::class . ' objects is expected.'); |
|
1076 | + throw new \InvalidArgumentException('An array of '.GoogleImage::class.' objects is expected.'); |
|
1080 | 1077 | } |
1081 | 1078 | $destPath = $destPathCallback($image); |
1082 | 1079 | $mapping[$destPath] = $image->getUrl(); |
1083 | 1080 | } |
1084 | 1081 | |
1085 | 1082 | $httpClient = $this->getHttpClient(); |
1086 | - $promises = (static function () use ($mapping, $overwrite, $httpClient) { |
|
1083 | + $promises = (static function() use ($mapping, $overwrite, $httpClient) { |
|
1087 | 1084 | foreach ($mapping as $destPath => $url) { |
1088 | 1085 | if (!$overwrite && is_file($destPath)) { |
1089 | 1086 | yield $destPath => new FulfilledPromise($url); |
@@ -1098,7 +1095,7 @@ discard block |
||
1098 | 1095 | RequestOptions::SINK => $destPath, |
1099 | 1096 | RequestOptions::HTTP_ERRORS => true, |
1100 | 1097 | ]) |
1101 | - ->then(static function ( |
|
1098 | + ->then(static function( |
|
1102 | 1099 | /** @noinspection PhpUnusedParameterInspection */ |
1103 | 1100 | ResponseInterface $response |
1104 | 1101 | ) use ($url) { |
@@ -1114,10 +1111,10 @@ discard block |
||
1114 | 1111 | $imageInfoList = []; |
1115 | 1112 | (new EachPromise($promises, [ |
1116 | 1113 | 'concurrency' => $this->concurrency, |
1117 | - 'fulfilled' => static function (string $url, string $destPath) use (&$imageInfoList) { |
|
1114 | + 'fulfilled' => static function(string $url, string $destPath) use (&$imageInfoList) { |
|
1118 | 1115 | $imageInfoList[] = new ImageInfo($url, $destPath); |
1119 | 1116 | }, |
1120 | - 'rejected' => static function (\Throwable $reason, string $key) use ($mapping) { |
|
1117 | + 'rejected' => static function(\Throwable $reason, string $key) use ($mapping) { |
|
1121 | 1118 | $exceptionUrl = $mapping[$key]; |
1122 | 1119 | foreach ($mapping as $destPath => $url) { |
1123 | 1120 | if (is_file($destPath)) { |