Passed
Branch feature/refactoring (13cbf0)
by Alexey
03:46
created
src/GPlayApps.php 1 patch
Spacing   +28 added lines, -32 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
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;
@@ -310,18 +310,18 @@  discard block
 block discarded – undo
310 310
          */
311 311
         $list = array_filter(
312 312
             $list,
313
-            static function (Model\AppInfo $app) {
313
+            static function(Model\AppInfo $app) {
314 314
                 return !$app->isAutoTranslatedDescription();
315 315
             }
316 316
         );
317 317
 
318 318
         if (!isset($list[$preferredLocale])) {
319
-            throw new \RuntimeException('No key ' . $preferredLocale);
319
+            throw new \RuntimeException('No key '.$preferredLocale);
320 320
         }
321 321
         $preferredApp = $list[$preferredLocale];
322 322
         $list = array_filter(
323 323
             $list,
324
-            static function (Model\AppInfo $app, string $locale) use ($preferredApp, $list) {
324
+            static function(Model\AppInfo $app, string $locale) use ($preferredApp, $list) {
325 325
                 // deletes locales in which there is no translation added, but automatic translation by Google Translate is used.
326 326
                 if ($preferredApp->getLocale() === $locale || !$preferredApp->equals($app)) {
327 327
                     if (($pos = strpos($locale, '_')) !== false) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         // sorting array keys; the first key is the preferred locale
351 351
         uksort(
352 352
             $list,
353
-            static function (
353
+            static function(
354 354
                 /** @noinspection PhpUnusedParameterInspection */
355 355
                 string $a,
356 356
                 string $b
@@ -460,14 +460,12 @@  discard block
 block discarded – undo
460 460
         $allReviews = [];
461 461
 
462 462
         $cacheTtl = $sort === Enum\SortEnum::NEWEST() ?
463
-            \DateInterval::createFromDateString('1 min') :
464
-            \DateInterval::createFromDateString('1 hour');
463
+            \DateInterval::createFromDateString('1 min') : \DateInterval::createFromDateString('1 hour');
465 464
 
466 465
         try {
467 466
             do {
468 467
                 $count = $limit === self::UNLIMIT ?
469
-                    Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE :
470
-                    min(Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1));
468
+                    Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE : min(Scraper\PlayStoreUiRequest::LIMIT_REVIEW_ON_PAGE, max($limit - $allCount, 1));
471 469
 
472 470
                 $request = Scraper\PlayStoreUiRequest::getReviewsRequest($appId, $count, $sort, $token);
473 471
 
@@ -507,7 +505,7 @@  discard block
 block discarded – undo
507 505
             /** @var Model\Review $review */
508 506
             $review = $this->getHttpClient()->request(
509 507
                 'GET',
510
-                self::GOOGLE_PLAY_APPS_URL . '/details',
508
+                self::GOOGLE_PLAY_APPS_URL.'/details',
511 509
                 [
512 510
                     RequestOptions::QUERY => [
513 511
                         self::REQ_PARAM_ID => $appId->getId(),
@@ -616,7 +614,7 @@  discard block
 block discarded – undo
616 614
         $url = self::GOOGLE_PLAY_APPS_URL;
617 615
 
618 616
         foreach ($locales as $locale) {
619
-            $urls[$locale] = $url . '?' . http_build_query(
617
+            $urls[$locale] = $url.'?'.http_build_query(
620 618
                 [
621 619
                     self::REQ_PARAM_LOCALE => $locale,
622 620
                 ]
@@ -681,7 +679,7 @@  discard block
 block discarded – undo
681 679
             );
682 680
         }
683 681
 
684
-        $url = self::GOOGLE_PLAY_APPS_URL . '/dev';
682
+        $url = self::GOOGLE_PLAY_APPS_URL.'/dev';
685 683
 
686 684
         try {
687 685
             /** @var Model\Developer $developer */
@@ -741,10 +739,10 @@  discard block
 block discarded – undo
741 739
         }
742 740
 
743 741
         $urls = [];
744
-        $url = self::GOOGLE_PLAY_APPS_URL . '/dev';
742
+        $url = self::GOOGLE_PLAY_APPS_URL.'/dev';
745 743
 
746 744
         foreach ($locales as $locale) {
747
-            $urls[$locale] = $url . '?' . http_build_query(
745
+            $urls[$locale] = $url.'?'.http_build_query(
748 746
                 [
749 747
                     self::REQ_PARAM_ID => $id,
750 748
                     self::REQ_PARAM_LOCALE => $locale,
@@ -790,7 +788,7 @@  discard block
 block discarded – undo
790 788
         ];
791 789
 
792 790
         if (is_numeric($developerId)) {
793
-            $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/dev?' . http_build_query($query);
791
+            $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/dev?'.http_build_query($query);
794 792
 
795 793
             try {
796 794
                 /**
@@ -807,13 +805,13 @@  discard block
 block discarded – undo
807 805
                 if ($developerUrl === null) {
808 806
                     return [];
809 807
                 }
810
-                $developerUrl .= '&' . self::REQ_PARAM_LOCALE . '=' . urlencode($this->defaultLocale) .
811
-                    '&' . self::REQ_PARAM_COUNTRY . '=' . urlencode($this->defaultCountry);
808
+                $developerUrl .= '&'.self::REQ_PARAM_LOCALE.'='.urlencode($this->defaultLocale).
809
+                    '&'.self::REQ_PARAM_COUNTRY.'='.urlencode($this->defaultCountry);
812 810
             } catch (\Throwable $e) {
813 811
                 throw new Exception\GooglePlayException($e->getMessage(), 1, $e);
814 812
             }
815 813
         } else {
816
-            $developerUrl = self::GOOGLE_PLAY_APPS_URL . '/developer?' . http_build_query($query);
814
+            $developerUrl = self::GOOGLE_PLAY_APPS_URL.'/developer?'.http_build_query($query);
817 815
         }
818 816
 
819 817
         return $this->fetchAppsFromClusterPage(
@@ -863,8 +861,7 @@  discard block
 block discarded – undo
863 861
 
864 862
             while ($token !== null && ($limit === self::UNLIMIT || $allCount < $limit)) {
865 863
                 $count = $limit === self::UNLIMIT ?
866
-                    Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE :
867
-                    min(Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1));
864
+                    Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE : min(Scraper\PlayStoreUiRequest::LIMIT_APPS_ON_PAGE, max($limit - $allCount, 1));
868 865
 
869 866
                 $request = Scraper\PlayStoreUiRequest::getAppsRequest($locale, $country, $count, $token);
870 867
 
@@ -1018,7 +1015,7 @@  discard block
 block discarded – undo
1018 1015
             self::REQ_PARAM_COUNTRY => $this->defaultCountry,
1019 1016
             'price' => $price->value(),
1020 1017
         ];
1021
-        $clusterPageUrl = self::GOOGLE_PLAY_URL . '/store/search?' . http_build_query($params);
1018
+        $clusterPageUrl = self::GOOGLE_PLAY_URL.'/store/search?'.http_build_query($params);
1022 1019
 
1023 1020
         return $this->fetchAppsFromClusterPage(
1024 1021
             $clusterPageUrl,
@@ -1123,13 +1120,13 @@  discard block
 block discarded – undo
1123 1120
         $url = self::GOOGLE_PLAY_APPS_URL;
1124 1121
 
1125 1122
         if ($path !== null) {
1126
-            $url .= '/' . $path;
1123
+            $url .= '/'.$path;
1127 1124
         }
1128 1125
 
1129 1126
         if ($category !== null) {
1130
-            $url .= '/category/' . Util\Caster::castToCategoryId($category);
1127
+            $url .= '/category/'.Util\Caster::castToCategoryId($category);
1131 1128
         }
1132
-        $url .= '?' . http_build_query($queryParams);
1129
+        $url .= '?'.http_build_query($queryParams);
1133 1130
 
1134 1131
         /**
1135 1132
          * @var array $categoryClusterPages = [[
@@ -1221,7 +1218,7 @@  discard block
 block discarded – undo
1221 1218
         foreach ($images as $image) {
1222 1219
             if (!$image instanceof Model\GoogleImage) {
1223 1220
                 throw new \InvalidArgumentException(
1224
-                    'An array of ' . Model\GoogleImage::class . ' objects is expected.'
1221
+                    'An array of '.Model\GoogleImage::class.' objects is expected.'
1225 1222
                 );
1226 1223
             }
1227 1224
             $destPath = $destPathCallback($image);
@@ -1230,7 +1227,7 @@  discard block
 block discarded – undo
1230 1227
         }
1231 1228
 
1232 1229
         $httpClient = $this->getHttpClient();
1233
-        $promises = (static function () use ($mapping, $overwrite, $httpClient) {
1230
+        $promises = (static function() use ($mapping, $overwrite, $httpClient) {
1234 1231
             foreach ($mapping as $url => $stream) {
1235 1232
                 $destPath = $stream->getFilename();
1236 1233
                 $dynamicPath = strpos($destPath, '{url}') !== false;
@@ -1246,7 +1243,7 @@  discard block
 block discarded – undo
1246 1243
                                 RequestOptions::COOKIES => null,
1247 1244
                                 RequestOptions::SINK => $stream,
1248 1245
                                 RequestOptions::HTTP_ERRORS => true,
1249
-                                RequestOptions::ON_HEADERS => static function (ResponseInterface $response) use (
1246
+                                RequestOptions::ON_HEADERS => static function(ResponseInterface $response) use (
1250 1247
                                     $url,
1251 1248
                                     $stream
1252 1249
                                 ): void {
@@ -1255,7 +1252,7 @@  discard block
 block discarded – undo
1255 1252
                             ]
1256 1253
                         )
1257 1254
                         ->then(
1258
-                            static function (
1255
+                            static function(
1259 1256
                                 /** @noinspection PhpUnusedParameterInspection */
1260 1257
                                 ResponseInterface $response
1261 1258
                             ) use ($url) {
@@ -1275,10 +1272,10 @@  discard block
 block discarded – undo
1275 1272
             $promises,
1276 1273
             [
1277 1274
                 'concurrency' => $this->concurrency,
1278
-                'fulfilled' => static function (string $url) use (&$imageInfoList, $mapping): void {
1275
+                'fulfilled' => static function(string $url) use (&$imageInfoList, $mapping): void {
1279 1276
                     $imageInfoList[] = new Model\ImageInfo($url, $mapping[$url]->getFilename());
1280 1277
                 },
1281
-                'rejected' => static function (\Throwable $reason, string $exceptionUrl) use ($mapping): void {
1278
+                'rejected' => static function(\Throwable $reason, string $exceptionUrl) use ($mapping): void {
1282 1279
                     foreach ($mapping as $destPath => $url) {
1283 1280
                         if (is_file($destPath)) {
1284 1281
                             unlink($destPath);
@@ -1343,8 +1340,7 @@  discard block
 block discarded – undo
1343 1340
     public function setDefaultCountry(string $defaultCountry): self
1344 1341
     {
1345 1342
         $this->defaultCountry = !empty($defaultCountry) ?
1346
-            $defaultCountry :
1347
-            self::DEFAULT_COUNTRY;
1343
+            $defaultCountry : self::DEFAULT_COUNTRY;
1348 1344
 
1349 1345
         return $this;
1350 1346
     }
Please login to merge, or discard this patch.
src/Model/AppId.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function getUrl(): string
101 101
     {
102
-        return GPlayApps::GOOGLE_PLAY_APPS_URL . '/details?' . http_build_query(
102
+        return GPlayApps::GOOGLE_PLAY_APPS_URL.'/details?'.http_build_query(
103 103
             [
104 104
                 GPlayApps::REQ_PARAM_ID => $this->id,
105 105
             ]
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function getFullUrl(): string
117 117
     {
118
-        return GPlayApps::GOOGLE_PLAY_APPS_URL . '/details?' . http_build_query(
118
+        return GPlayApps::GOOGLE_PLAY_APPS_URL.'/details?'.http_build_query(
119 119
             [
120 120
                 GPlayApps::REQ_PARAM_ID => $this->id,
121 121
                 GPlayApps::REQ_PARAM_LOCALE => $this->locale,
Please login to merge, or discard this patch.
src/Model/Developer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,21 +82,21 @@
 block discarded – undo
82 82
 
83 83
         if (empty($this->id)) {
84 84
             throw new \InvalidArgumentException(
85
-                'Developer id cannot be null or empty. ' .
85
+                'Developer id cannot be null or empty. '.
86 86
                 'Solution: $developerBuilder->setId(...);'
87 87
             );
88 88
         }
89 89
 
90 90
         if (empty($this->url)) {
91 91
             throw new \InvalidArgumentException(
92
-                'Developer url cannot be null or empty. ' .
92
+                'Developer url cannot be null or empty. '.
93 93
                 'Solution: $developerBuilder->setUrl(...);'
94 94
             );
95 95
         }
96 96
 
97 97
         if (empty($this->name)) {
98 98
             throw new \InvalidArgumentException(
99
-                'Developer name cannot be null or empty. ' .
99
+                'Developer name cannot be null or empty. '.
100 100
                 'Solution: $developerBuilder->setName(...);'
101 101
             );
102 102
         }
Please login to merge, or discard this patch.
src/Model/GoogleImage.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             }
192 192
             $parts = \array_slice($parts, 0, 4);
193 193
             $path = implode('/', $parts);
194
-            $url = $httpComponents['scheme'] . '://' . $httpComponents['host'] . '/' . $path . '/';
194
+            $url = $httpComponents['scheme'].'://'.$httpComponents['host'].'/'.$path.'/';
195 195
             $this->variantOfUrlWithFileName = true;
196 196
         } elseif (($pos = strpos($url, '=')) !== false) {
197 197
             $paramString = substr($url, $pos + 1);
@@ -272,14 +272,14 @@  discard block
 block discarded – undo
272 272
         $params = [];
273 273
 
274 274
         if ($this->size !== null) {
275
-            $params[] = self::PARAM_SIZE . $this->size;
275
+            $params[] = self::PARAM_SIZE.$this->size;
276 276
         } else {
277 277
             if ($this->width !== null) {
278
-                $params[] = self::PARAM_WIDTH . $this->width;
278
+                $params[] = self::PARAM_WIDTH.$this->width;
279 279
             }
280 280
 
281 281
             if ($this->height !== null) {
282
-                $params[] = self::PARAM_HEIGHT . $this->height;
282
+                $params[] = self::PARAM_HEIGHT.$this->height;
283 283
             }
284 284
         }
285 285
 
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
                 return $this->baseUrl;
295 295
             }
296 296
 
297
-            return $this->baseUrl . implode('-', $params) . '/';
297
+            return $this->baseUrl.implode('-', $params).'/';
298 298
         }
299 299
 
300 300
         if ($this->border !== null) {
301
-            $params[] = self::PARAM_BORDER . $this->border;
301
+            $params[] = self::PARAM_BORDER.$this->border;
302 302
         }
303 303
 
304 304
         if ($this->verticalFlip) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             return $this->baseUrl;
314 314
         }
315 315
 
316
-        return $this->baseUrl . '=' . implode('-', $params);
316
+        return $this->baseUrl.'='.implode('-', $params);
317 317
     }
318 318
 
319 319
     /**
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function getOriginalSizeUrl(): string
337 337
     {
338
-        $params = [self::PARAM_SIZE . '0'];
338
+        $params = [self::PARAM_SIZE.'0'];
339 339
 
340 340
         if ($this->variantOfUrlWithFileName) {
341
-            return $this->baseUrl . implode('-', $params) . '/';
341
+            return $this->baseUrl.implode('-', $params).'/';
342 342
         }
343 343
 
344
-        return $this->baseUrl . '=' . implode('-', $params);
344
+        return $this->baseUrl.'='.implode('-', $params);
345 345
     }
346 346
 
347 347
     /**
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             for ($i = 0; $i < $parts; $i++) {
367 367
                 $partsBuild[] = substr($hash, $i * $partLength, $partLength);
368 368
             }
369
-            $hash = implode('/', $partsBuild) . '/' . $hash;
369
+            $hash = implode('/', $partsBuild).'/'.$hash;
370 370
         }
371 371
 
372 372
         return $hash;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                     RequestOptions::COOKIES => null,
632 632
                     RequestOptions::HTTP_ERRORS => true,
633 633
                     RequestOptions::SINK => $stream,
634
-                    RequestOptions::ON_HEADERS => static function (ResponseInterface $response) use (
634
+                    RequestOptions::ON_HEADERS => static function(ResponseInterface $response) use (
635 635
                         $url,
636 636
                         $stream
637 637
                     ): void {
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
         $contentType = $response->getHeaderLine('Content-Type');
669 669
 
670 670
         if (!preg_match('~\bimage/.*\b~i', $contentType, $match)) {
671
-            throw new GooglePlayException('Url ' . $url . ' is not image');
671
+            throw new GooglePlayException('Url '.$url.' is not image');
672 672
         }
673 673
         $contentType = $match[0];
674 674
         $imageType = self::getImageExtension($contentType);
Please login to merge, or discard this patch.
src/Model/ImageInfo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         $imageInfo = getimagesize($filename);
52 52
 
53 53
         if (!$imageInfo) {
54
-            throw new \RuntimeException('Invalid image: ' . $filename);
54
+            throw new \RuntimeException('Invalid image: '.$filename);
55 55
         }
56 56
         $this->filename = $filename;
57 57
         $this->mimeType = $imageInfo['mime'];
Please login to merge, or discard this patch.
src/Model/AppInfo.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         $diff = array_udiff(
520 520
             $otherApp->screenshots,
521 521
             $this->screenshots,
522
-            static function (GoogleImage $a, GoogleImage $b) {
522
+            static function(GoogleImage $a, GoogleImage $b) {
523 523
                 return strcmp($a->getOriginalSizeUrl(), $b->getOriginalSizeUrl());
524 524
             }
525 525
         );
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         $array['translatedFromLocale'] = $this->translatedFromLocale;
540 540
         $array['cover'] = $this->cover !== null ? $this->cover->getUrl() : null;
541 541
         $array['screenshots'] = array_map(
542
-            static function (GoogleImage $googleImage) {
542
+            static function(GoogleImage $googleImage) {
543 543
                 return $googleImage->getUrl();
544 544
             },
545 545
             $this->screenshots
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
         $array['updatedTimestamp'] = $this->updated !== null ? $this->updated->getTimestamp() : 0;
570 570
         $array['numberReviews'] = $this->numberReviews;
571 571
         $array['reviews'] = array_map(
572
-            static function (Review $review) {
572
+            static function(Review $review) {
573 573
                 return $review->asArray();
574 574
             },
575 575
             $this->reviews
Please login to merge, or discard this patch.
src/Util/DateStringFormatter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
             if (isset($datePatternObj['months'])) {
1191 1191
                 if (!isset($datePatternObj['months'][$month])) {
1192 1192
                     throw new \RuntimeException(
1193
-                        'Error convert date. Locale ' . $locale . '. Date: ' . $dateText .
1194
-                        '. Matches: ' . var_export($match, true)
1193
+                        'Error convert date. Locale '.$locale.'. Date: '.$dateText.
1194
+                        '. Matches: '.var_export($match, true)
1195 1195
                     );
1196 1196
                 }
1197 1197
                 $month = $datePatternObj['months'][$month];
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 
1204 1204
             $dateTime = \DateTimeImmutable::createFromFormat(
1205 1205
                 'Y.m.d H:i:s',
1206
-                $year . '.' . $month . '.' . $day . ' 00:00:00',
1206
+                $year.'.'.$month.'.'.$day.' 00:00:00',
1207 1207
                 new \DateTimeZone('UTC')
1208 1208
             );
1209 1209
 
Please login to merge, or discard this patch.
src/Util/ScraperUtil.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         if (preg_match_all('/>AF_initDataCallback[\s\S]*?<\/script/', $html, $matches)) {
29 29
             $scripts = array_reduce(
30 30
                 $matches[0],
31
-                static function ($carry, $item) {
31
+                static function($carry, $item) {
32 32
                     if (
33 33
                         preg_match("/(ds:.*?)'/", $item, $keyMatch) &&
34 34
                         preg_match('/return ([\s\S]*?)}}\);<\//', $item, $valueMatch)
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
         $doc = new \DOMDocument();
56 56
         $internalErrors = libxml_use_internal_errors(true);
57 57
 
58
-        if (!$doc->loadHTML('<?xml encoding="utf-8"?>' . $html)) {
58
+        if (!$doc->loadHTML('<?xml encoding="utf-8"?>'.$html)) {
59 59
             throw new
60 60
             \RuntimeException(
61
-                'error load html: ' . $html
61
+                'error load html: '.$html
62 62
             );
63 63
         }
64 64
         libxml_use_internal_errors($internalErrors);
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
                 case 'p':
109 109
                 case 'ul':
110 110
                 case 'div':
111
-                    $text = "\n\n" . $text . "\n\n";
111
+                    $text = "\n\n".$text."\n\n";
112 112
                     break;
113 113
 
114 114
                 case 'li':
115
-                    $text = '- ' . $text . "\n";
115
+                    $text = '- '.$text."\n";
116 116
                     break;
117 117
 
118 118
                 case 'br':
Please login to merge, or discard this patch.