| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 | public const GOOGLE_PLAY_URL = 'https://play.google.com'; | 
| 36 | 36 | |
| 37 | 37 | /** @var string Google Play apps url. */ | 
| 38 | - public const GOOGLE_PLAY_APPS_URL = self::GOOGLE_PLAY_URL . '/store/apps'; | |
| 38 | + public const GOOGLE_PLAY_APPS_URL = self::GOOGLE_PLAY_URL.'/store/apps'; | |
| 39 | 39 | |
| 40 | 40 | /** @var int Unlimit results. */ | 
| 41 | 41 | public const UNLIMIT = -1; | 
| @@ -317,18 +317,18 @@ discard block | ||
| 317 | 317 | */ | 
| 318 | 318 | $list = array_filter( | 
| 319 | 319 | $list, | 
| 320 | -            static function (Model\AppInfo $app) { | |
| 320 | +            static function(Model\AppInfo $app) { | |
| 321 | 321 | return !$app->isAutoTranslatedDescription(); | 
| 322 | 322 | } | 
| 323 | 323 | ); | 
| 324 | 324 | |
| 325 | 325 |          if (!isset($list[$preferredLocale])) { | 
| 326 | -            throw new \RuntimeException('No key ' . $preferredLocale); | |
| 326 | +            throw new \RuntimeException('No key '.$preferredLocale); | |
| 327 | 327 | } | 
| 328 | 328 | $preferredApp = $list[$preferredLocale]; | 
| 329 | 329 | $list = array_filter( | 
| 330 | 330 | $list, | 
| 331 | -            static function (Model\AppInfo $app, string $locale) use ($preferredApp, $list) { | |
| 331 | +            static function(Model\AppInfo $app, string $locale) use ($preferredApp, $list) { | |
| 332 | 332 | // deletes locales in which there is no translation added, but automatic translation by Google Translate is used. | 
| 333 | 333 |                  if ($preferredApp->getLocale() === $locale || !$preferredApp->equals($app)) { | 
| 334 | 334 |                      if (($pos = strpos($locale, '_')) !== false) { | 
| @@ -357,7 +357,7 @@ discard block | ||
| 357 | 357 | // sorting array keys; the first key is the preferred locale | 
| 358 | 358 | uksort( | 
| 359 | 359 | $list, | 
| 360 | - static function ( | |
| 360 | + static function( | |
| 361 | 361 | /** @noinspection PhpUnusedParameterInspection */ | 
| 362 | 362 | string $a, | 
| 363 | 363 | string $b | 
| @@ -467,14 +467,12 @@ discard block | ||
| 467 | 467 | $allReviews = []; | 
| 468 | 468 | |
| 469 | 469 | $cacheTtl = $sort === Enum\SortEnum::NEWEST() ? | 
| 470 | -            \DateInterval::createFromDateString('1 min') : | |
| 471 | -            \DateInterval::createFromDateString('1 hour'); | |
| 470 | +            \DateInterval::createFromDateString('1 min') : \DateInterval::createFromDateString('1 hour'); | |
| 472 | 471 | |
| 473 | 472 |          try { | 
| 474 | 473 |              do { | 
| 475 | 474 | $count = $limit === self::UNLIMIT ? | 
| 476 | - Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE : | |
| 477 | - min(Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1)); | |
| 475 | + Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE : min(Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1)); | |
| 478 | 476 | |
| 479 | 477 | $request = Scraper\PlayStoreUiRequest::getReviewsRequest($appId, $count, $sort, $token); | 
| 480 | 478 | |
| @@ -514,7 +512,7 @@ discard block | ||
| 514 | 512 | /** @var Model\Review $review */ | 
| 515 | 513 | $review = $this->getHttpClient()->request( | 
| 516 | 514 | 'GET', | 
| 517 | - self::GOOGLE_PLAY_APPS_URL . '/details', | |
| 515 | + self::GOOGLE_PLAY_APPS_URL.'/details', | |
| 518 | 516 | [ | 
| 519 | 517 | RequestOptions::QUERY => [ | 
| 520 | 518 | self::REQ_PARAM_ID => $appId->getId(), | 
| @@ -623,7 +621,7 @@ discard block | ||
| 623 | 621 | $url = self::GOOGLE_PLAY_APPS_URL; | 
| 624 | 622 | |
| 625 | 623 |          foreach ($locales as $locale) { | 
| 626 | - $urls[$locale] = $url . '?' . http_build_query( | |
| 624 | + $urls[$locale] = $url.'?'.http_build_query( | |
| 627 | 625 | [ | 
| 628 | 626 | self::REQ_PARAM_LOCALE => $locale, | 
| 629 | 627 | ] | 
| @@ -688,7 +686,7 @@ discard block | ||
| 688 | 686 | ); | 
| 689 | 687 | } | 
| 690 | 688 | |
| 691 | - $url = self::GOOGLE_PLAY_APPS_URL . '/dev'; | |
| 689 | + $url = self::GOOGLE_PLAY_APPS_URL.'/dev'; | |
| 692 | 690 | |
| 693 | 691 |          try { | 
| 694 | 692 | /** @var Model\Developer $developer */ | 
| @@ -748,10 +746,10 @@ discard block | ||
| 748 | 746 | } | 
| 749 | 747 | |
| 750 | 748 | $urls = []; | 
| 751 | - $url = self::GOOGLE_PLAY_APPS_URL . '/dev'; | |
| 749 | + $url = self::GOOGLE_PLAY_APPS_URL.'/dev'; | |
| 752 | 750 | |
| 753 | 751 |          foreach ($locales as $locale) { | 
| 754 | - $urls[$locale] = $url . '?' . http_build_query( | |
| 752 | + $urls[$locale] = $url.'?'.http_build_query( | |
| 755 | 753 | [ | 
| 756 | 754 | self::REQ_PARAM_ID => $id, | 
| 757 | 755 | self::REQ_PARAM_LOCALE => $locale, | 
| @@ -797,7 +795,7 @@ discard block | ||
| 797 | 795 | ]; | 
| 798 | 796 | |
| 799 | 797 |          if (is_numeric($developerId)) { | 
| 800 | - $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/dev?' . http_build_query($query); | |
| 798 | + $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/dev?'.http_build_query($query); | |
| 801 | 799 | |
| 802 | 800 |              try { | 
| 803 | 801 | /** | 
| @@ -814,13 +812,13 @@ discard block | ||
| 814 | 812 |                  if ($developerUrl === null) { | 
| 815 | 813 | return []; | 
| 816 | 814 | } | 
| 817 | - $developerUrl .= '&' . self::REQ_PARAM_LOCALE . '=' . urlencode($this->defaultLocale) . | |
| 818 | - '&' . self::REQ_PARAM_COUNTRY . '=' . urlencode($this->defaultCountry); | |
| 815 | + $developerUrl .= '&'.self::REQ_PARAM_LOCALE.'='.urlencode($this->defaultLocale). | |
| 816 | + '&'.self::REQ_PARAM_COUNTRY.'='.urlencode($this->defaultCountry); | |
| 819 | 817 |              } catch (\Throwable $e) { | 
| 820 | 818 | throw new Exception\GooglePlayException($e->getMessage(), 1, $e); | 
| 821 | 819 | } | 
| 822 | 820 |          } else { | 
| 823 | - $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/developer?' . http_build_query($query); | |
| 821 | + $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/developer?'.http_build_query($query); | |
| 824 | 822 | } | 
| 825 | 823 | |
| 826 | 824 | return $this->fetchAppsFromClusterPage( | 
| @@ -861,10 +859,10 @@ discard block | ||
| 861 | 859 | $query[self::REQ_PARAM_LOCALE] = $locale; | 
| 862 | 860 | $query[self::REQ_PARAM_COUNTRY] = $country; | 
| 863 | 861 | |
| 864 | - $clusterPageUrl = $clusterPageComponents['scheme'] . '://' . | |
| 865 | - $clusterPageComponents['host'] . | |
| 866 | - $clusterPageComponents['path'] . | |
| 867 | - '?' . Query::build($query); | |
| 862 | + $clusterPageUrl = $clusterPageComponents['scheme'].'://'. | |
| 863 | + $clusterPageComponents['host']. | |
| 864 | + $clusterPageComponents['path']. | |
| 865 | + '?'.Query::build($query); | |
| 868 | 866 | |
| 869 | 867 |          try { | 
| 870 | 868 | [$apps, $token] = $this->getHttpClient()->request( | 
| @@ -880,8 +878,7 @@ discard block | ||
| 880 | 878 | |
| 881 | 879 |              while ($token !== null && ($limit === self::UNLIMIT || $allCount < $limit)) { | 
| 882 | 880 | $count = $limit === self::UNLIMIT ? | 
| 883 | - Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE : | |
| 884 | - min(Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1)); | |
| 881 | + Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE : min(Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1)); | |
| 885 | 882 | |
| 886 | 883 | $request = Scraper\PlayStoreUiRequest::getAppsRequest($locale, $country, $count, $token); | 
| 887 | 884 | |
| @@ -1027,7 +1024,7 @@ discard block | ||
| 1027 | 1024 | self::REQ_PARAM_COUNTRY => $this->defaultCountry, | 
| 1028 | 1025 | 'price' => $price->value(), | 
| 1029 | 1026 | ]; | 
| 1030 | - $clusterPageUrl = self::GOOGLE_PLAY_URL . '/store/search?' . http_build_query($params); | |
| 1027 | + $clusterPageUrl = self::GOOGLE_PLAY_URL.'/store/search?'.http_build_query($params); | |
| 1031 | 1028 | |
| 1032 | 1029 | return $this->fetchAppsFromClusterPage( | 
| 1033 | 1030 | $clusterPageUrl, | 
| @@ -1132,13 +1129,13 @@ discard block | ||
| 1132 | 1129 | $url = self::GOOGLE_PLAY_APPS_URL; | 
| 1133 | 1130 | |
| 1134 | 1131 |          if ($path !== null) { | 
| 1135 | - $url .= '/' . $path; | |
| 1132 | + $url .= '/'.$path; | |
| 1136 | 1133 | } | 
| 1137 | 1134 | |
| 1138 | 1135 |          if ($category !== null) { | 
| 1139 | - $url .= '/category/' . Util\Caster::castToCategoryId($category); | |
| 1136 | + $url .= '/category/'.Util\Caster::castToCategoryId($category); | |
| 1140 | 1137 | } | 
| 1141 | - $url .= '?' . http_build_query($queryParams); | |
| 1138 | + $url .= '?'.http_build_query($queryParams); | |
| 1142 | 1139 | |
| 1143 | 1140 | /** | 
| 1144 | 1141 | * @var array $categoryClusterPages = [[ | 
| @@ -1230,7 +1227,7 @@ discard block | ||
| 1230 | 1227 |          foreach ($images as $image) { | 
| 1231 | 1228 |              if (!$image instanceof Model\GoogleImage) { | 
| 1232 | 1229 | throw new \InvalidArgumentException( | 
| 1233 | - 'An array of ' . Model\GoogleImage::class . ' objects is expected.' | |
| 1230 | + 'An array of '.Model\GoogleImage::class.' objects is expected.' | |
| 1234 | 1231 | ); | 
| 1235 | 1232 | } | 
| 1236 | 1233 | $destPath = $destPathCallback($image); | 
| @@ -1239,7 +1236,7 @@ discard block | ||
| 1239 | 1236 | } | 
| 1240 | 1237 | |
| 1241 | 1238 | $httpClient = $this->getHttpClient(); | 
| 1242 | -        $promises = (static function () use ($mapping, $overwrite, $httpClient) { | |
| 1239 | +        $promises = (static function() use ($mapping, $overwrite, $httpClient) { | |
| 1243 | 1240 |              foreach ($mapping as $url => $stream) { | 
| 1244 | 1241 | $destPath = $stream->getFilename(); | 
| 1245 | 1242 |                  $dynamicPath = strpos($destPath, '{url}') !== false; | 
| @@ -1255,7 +1252,7 @@ discard block | ||
| 1255 | 1252 | RequestOptions::COOKIES => null, | 
| 1256 | 1253 | RequestOptions::SINK => $stream, | 
| 1257 | 1254 | RequestOptions::HTTP_ERRORS => true, | 
| 1258 | - RequestOptions::ON_HEADERS => static function (ResponseInterface $response) use ( | |
| 1255 | + RequestOptions::ON_HEADERS => static function(ResponseInterface $response) use ( | |
| 1259 | 1256 | $url, | 
| 1260 | 1257 | $stream | 
| 1261 | 1258 |                                  ): void { | 
| @@ -1264,7 +1261,7 @@ discard block | ||
| 1264 | 1261 | ] | 
| 1265 | 1262 | ) | 
| 1266 | 1263 | ->then( | 
| 1267 | - static function ( | |
| 1264 | + static function( | |
| 1268 | 1265 | /** @noinspection PhpUnusedParameterInspection */ | 
| 1269 | 1266 | ResponseInterface $response | 
| 1270 | 1267 |                              ) use ($url) { | 
| @@ -1284,10 +1281,10 @@ discard block | ||
| 1284 | 1281 | $promises, | 
| 1285 | 1282 | [ | 
| 1286 | 1283 | 'concurrency' => $this->concurrency, | 
| 1287 | -                'fulfilled' => static function (string $url) use (&$imageInfoList, $mapping): void { | |
| 1284 | +                'fulfilled' => static function(string $url) use (&$imageInfoList, $mapping): void { | |
| 1288 | 1285 | $imageInfoList[] = new Model\ImageInfo($url, $mapping[$url]->getFilename()); | 
| 1289 | 1286 | }, | 
| 1290 | -                'rejected' => static function (\Throwable $reason, string $exceptionUrl) use ($mapping): void { | |
| 1287 | +                'rejected' => static function(\Throwable $reason, string $exceptionUrl) use ($mapping): void { | |
| 1291 | 1288 |                      foreach ($mapping as $destPath => $url) { | 
| 1292 | 1289 |                          if (is_file($destPath)) { | 
| 1293 | 1290 | unlink($destPath); | 
| @@ -1356,8 +1353,7 @@ discard block | ||
| 1356 | 1353 | public function setDefaultCountry(string $defaultCountry): self | 
| 1357 | 1354 |      { | 
| 1358 | 1355 | $this->defaultCountry = !empty($defaultCountry) ? | 
| 1359 | - $defaultCountry : | |
| 1360 | - self::DEFAULT_COUNTRY; | |
| 1356 | + $defaultCountry : self::DEFAULT_COUNTRY; | |
| 1361 | 1357 | |
| 1362 | 1358 | return $this; | 
| 1363 | 1359 | } | 
| @@ -1206,7 +1206,7 @@ discard block | ||
| 1206 | 1206 | |
| 1207 | 1207 |          if (isset($datePatternObj['convert'])) { | 
| 1208 | 1208 | $convertedText = forward_static_call($datePatternObj['convert'], $dateText); | 
| 1209 | -            if ($convertedText !== false){ | |
| 1209 | +            if ($convertedText !== false) { | |
| 1210 | 1210 | $dateText = (string) $convertedText; | 
| 1211 | 1211 | } | 
| 1212 | 1212 | } | 
| @@ -1219,8 +1219,8 @@ discard block | ||
| 1219 | 1219 |              if (isset($datePatternObj['months'])) { | 
| 1220 | 1220 |                  if (!isset($datePatternObj['months'][$month])) { | 
| 1221 | 1221 | throw new \RuntimeException( | 
| 1222 | - 'Error convert date. Locale ' . $locale . '. Date: ' . $dateText . | |
| 1223 | - '. Matches: ' . var_export($match, true) | |
| 1222 | + 'Error convert date. Locale '.$locale.'. Date: '.$dateText. | |
| 1223 | + '. Matches: '.var_export($match, true) | |
| 1224 | 1224 | ); | 
| 1225 | 1225 | } | 
| 1226 | 1226 | $month = $datePatternObj['months'][$month]; | 
| @@ -1232,7 +1232,7 @@ discard block | ||
| 1232 | 1232 | |
| 1233 | 1233 | $dateTime = \DateTimeImmutable::createFromFormat( | 
| 1234 | 1234 | 'Y.m.d H:i:s', | 
| 1235 | - $year . '.' . $month . '.' . $day . ' 00:00:00', | |
| 1235 | + $year.'.'.$month.'.'.$day.' 00:00:00', | |
| 1236 | 1236 |                  new \DateTimeZone('UTC') | 
| 1237 | 1237 | ); | 
| 1238 | 1238 | |
| @@ -59,11 +59,11 @@ discard block | ||
| 59 | 59 | 'soc-platform' => 1, | 
| 60 | 60 | 'soc-device' => 1, | 
| 61 | 61 | ]; | 
| 62 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); | |
| 62 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); | |
| 63 | 63 | $formParams = [ | 
| 64 | - 'f.req' => '[[["' . self::RPC_ID_REVIEWS . '","[null,null,[2,' . $sort->value( | |
| 65 | - ) . ',[' . $limit . ',null,' . ($token === null ? 'null' : '\\"' . $token . '\\"') . | |
| 66 | - ']],[\\"' . $requestApp->getId() . '\\",7]]",null,"generic"]]]', | |
| 64 | + 'f.req' => '[[["'.self::RPC_ID_REVIEWS.'","[null,null,[2,'.$sort->value( | |
| 65 | + ).',['.$limit.',null,'.($token === null ? 'null' : '\\"'.$token.'\\"'). | |
| 66 | + ']],[\\"'.$requestApp->getId().'\\",7]]",null,"generic"]]]', | |
| 67 | 67 | ]; | 
| 68 | 68 | $headers = [ | 
| 69 | 69 | 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', | 
| @@ -92,9 +92,9 @@ discard block | ||
| 92 | 92 | 'soc-platform' => 1, | 
| 93 | 93 | 'soc-device' => 1, | 
| 94 | 94 | ]; | 
| 95 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); | |
| 95 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); | |
| 96 | 96 | $formParams = [ | 
| 97 | - 'f.req' => '[[["' . self::RPC_ID_APPS . '","[[null,[[10,[10,' . $limit . ']],true,null,[1]],null,\\"' . $token . '\\"]]",null,"generic"]]]', | |
| 97 | + 'f.req' => '[[["'.self::RPC_ID_APPS.'","[[null,[[10,[10,'.$limit.']],true,null,[1]],null,\\"'.$token.'\\"]]",null,"generic"]]]', | |
| 98 | 98 | ]; | 
| 99 | 99 | $headers = [ | 
| 100 | 100 | 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', | 
| @@ -121,10 +121,10 @@ discard block | ||
| 121 | 121 | 'soc-platform' => 1, | 
| 122 | 122 | 'soc-device' => 1, | 
| 123 | 123 | ]; | 
| 124 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); | |
| 124 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); | |
| 125 | 125 | $formParams = [ | 
| 126 | - 'f.req' => '[[["' . self::RPC_ID_PERMISSIONS . '","[[null,[\"' . | |
| 127 | - $requestApp->getId() . '\",7],[]]]",null,"1"]]]', | |
| 126 | + 'f.req' => '[[["'.self::RPC_ID_PERMISSIONS.'","[[null,[\"'. | |
| 127 | + $requestApp->getId().'\",7],[]]]",null,"1"]]]', | |
| 128 | 128 | ]; | 
| 129 | 129 | $headers = [ | 
| 130 | 130 | 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', | 
| @@ -158,10 +158,10 @@ discard block | ||
| 158 | 158 | 'soc-platform' => 1, | 
| 159 | 159 | 'soc-device' => 1, | 
| 160 | 160 | ]; | 
| 161 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); | |
| 161 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); | |
| 162 | 162 | $formParams = [ | 
| 163 | - 'f.req' => '[[["' . self::RPC_ID_SUGGEST . '","[[null,[\"' . | |
| 164 | -                str_replace('"', '\\\\\\"', $query) . | |
| 163 | + 'f.req' => '[[["'.self::RPC_ID_SUGGEST.'","[[null,[\"'. | |
| 164 | +                str_replace('"', '\\\\\\"', $query). | |
| 165 | 165 | '\"],[10],[2],4]]",null,"generic"]]]', | 
| 166 | 166 | ]; | 
| 167 | 167 | $headers = [ | 
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | $json = \GuzzleHttp\json_decode($contents, true); | 
| 26 | 26 | $suggests = \GuzzleHttp\json_decode($json[0][2], true); | 
| 27 | 27 | |
| 28 | -        return array_map(static function (array $suggest): string { | |
| 28 | +        return array_map(static function(array $suggest): string { | |
| 29 | 29 | return (string) $suggest[0]; | 
| 30 | 30 | }, $suggests[0][0] ?? []); | 
| 31 | 31 | } |