@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $doc = new \DOMDocument(); |
46 | 46 | $internalErrors = libxml_use_internal_errors(true); |
47 | - if (!$doc->loadHTML('<?xml encoding="utf-8" ?>' . $response->getBody()->getContents())) { |
|
47 | + if (!$doc->loadHTML('<?xml encoding="utf-8" ?>'.$response->getBody()->getContents())) { |
|
48 | 48 | throw new \RuntimeException('error load html'); |
49 | 49 | } |
50 | 50 | libxml_use_internal_errors($internalErrors); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | throw (new GooglePlayException('Error parse app list')) |
77 | 77 | ->setUrl($request->getUri()->__toString()); |
78 | 78 | } |
79 | - $url = GPlayApps::GOOGLE_PLAY_URL . $nodeTitle->attributes->getNamedItem('href')->textContent; |
|
79 | + $url = GPlayApps::GOOGLE_PLAY_URL.$nodeTitle->attributes->getNamedItem('href')->textContent; |
|
80 | 80 | $name = trim($nodeTitle->attributes->getNamedItem('title')->textContent); |
81 | 81 | } |
82 | 82 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | ->setUrl($request->getUri()->__toString()); |
130 | 130 | } |
131 | 131 | $developerName = trim($developerNode->textContent); |
132 | - $developerUrl = GPlayApps::GOOGLE_PLAY_URL . $developerNode->attributes->getNamedItem('href')->textContent; |
|
132 | + $developerUrl = GPlayApps::GOOGLE_PLAY_URL.$developerNode->attributes->getNamedItem('href')->textContent; |
|
133 | 133 | $developerId = parse_query(parse_url($developerUrl, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
134 | 134 | $developer = new Developer( |
135 | 135 | Developer::newBuilder() |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | throw (new GooglePlayException('Error parse app list icon node')) |
155 | 155 | ->setUrl($request->getUri()->__toString()); |
156 | 156 | } |
157 | - $icon = new GoogleImage('https:' . $iconNode->textContent); |
|
157 | + $icon = new GoogleImage('https:'.$iconNode->textContent); |
|
158 | 158 | $icon->reset(); |
159 | 159 | return $icon; |
160 | 160 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | $urlComponents = parse_url($url); |
28 | 28 | $query = parse_query($urlComponents['query']); |
29 | 29 | $developerId = $query[GPlayApps::REQ_PARAM_ID]; |
30 | - $url = $urlComponents['scheme'] . '://' |
|
30 | + $url = $urlComponents['scheme'].'://' |
|
31 | 31 | . $urlComponents['host'] |
32 | 32 | . $urlComponents['path'] |
33 | - . '?' . http_build_query([GPlayApps::REQ_PARAM_ID => $developerId]); |
|
33 | + . '?'.http_build_query([GPlayApps::REQ_PARAM_ID => $developerId]); |
|
34 | 34 | |
35 | 35 | $scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents()); |
36 | 36 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * @param RequestInterface $request |
20 | 20 | * @param ResponseInterface $response |
21 | - * @return mixed |
|
21 | + * @return Developer |
|
22 | 22 | * @throws GooglePlayException |
23 | 23 | */ |
24 | 24 | public function __invoke(RequestInterface $request, ResponseInterface $response) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | $name = $data[2]; |
22 | 22 | $appId = $data[12][0]; |
23 | - $url = GPlayApps::GOOGLE_PLAY_URL . $data[9][4][2]; |
|
23 | + $url = GPlayApps::GOOGLE_PLAY_URL.$data[9][4][2]; |
|
24 | 24 | $icon = new GoogleImage($data[1][1][0][3][2]); |
25 | 25 | $developer = self::extractDeveloper($data); |
26 | 26 | $price = $data[7][0][3][2][1][0][2]; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | private static function extractDeveloper(array $data): Developer |
49 | 49 | { |
50 | 50 | $developerName = $data[4][0][0][0]; |
51 | - $developerPage = GPlayApps::GOOGLE_PLAY_URL . $data[4][0][0][1][4][2]; |
|
51 | + $developerPage = GPlayApps::GOOGLE_PLAY_URL.$data[4][0][0][1][4][2]; |
|
52 | 52 | $developerId = parse_query(parse_url($developerPage, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
53 | 53 | $developer = new Developer( |
54 | 54 | Developer::newBuilder() |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $reviews = []; |
22 | 22 | foreach ($data as $reviewData) { |
23 | 23 | $reviewId = $reviewData[0]; |
24 | - $reviewUrl = $requestApp->getUrl() . '&reviewId=' . urlencode($reviewId); |
|
24 | + $reviewUrl = $requestApp->getUrl().'&reviewId='.urlencode($reviewId); |
|
25 | 25 | $userName = $reviewData[1][0]; |
26 | 26 | $avatar = new GoogleImage($reviewData[1][1][3][2]); |
27 | 27 | $date = null; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $date = DateStringFormatter::unixTimeToDateTime($reviewData[5][0]); |
30 | 30 | } |
31 | 31 | $score = $reviewData[2] ?? 0; |
32 | - $text = (string)($reviewData[4] ?? ''); |
|
32 | + $text = (string) ($reviewData[4] ?? ''); |
|
33 | 33 | $likeCount = $reviewData[6]; |
34 | 34 | |
35 | 35 | $reply = self::extractReplyReview($reviewData); |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | ScraperUtil::html2text($scriptDataInfo[0][10][1][1]); |
87 | 87 | |
88 | 88 | $installs = $scriptDataInfo[0][12][9][2] ?? 0; |
89 | - $score = (float)($scriptDataRating[0][6][0][1] ?? 0); |
|
90 | - $numberVoters = (int)($scriptDataRating[0][6][2][1] ?? 0); |
|
91 | - $reviewsCount = (int)($scriptDataRating[0][6][3][1] ?? 0); |
|
89 | + $score = (float) ($scriptDataRating[0][6][0][1] ?? 0); |
|
90 | + $numberVoters = (int) ($scriptDataRating[0][6][2][1] ?? 0); |
|
91 | + $reviewsCount = (int) ($scriptDataRating[0][6][3][1] ?? 0); |
|
92 | 92 | $histogram = $scriptDataRating[0][6][1] ?? null; |
93 | 93 | |
94 | 94 | $histogramRating = new HistogramRating( |
@@ -100,12 +100,11 @@ discard block |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | $price = isset($scriptDataPrice[0][2][0][0][0][1][0][0]) ? |
103 | - (float)($scriptDataPrice[0][2][0][0][0][1][0][0] / 1000000) : |
|
104 | - 0; |
|
103 | + (float) ($scriptDataPrice[0][2][0][0][0][1][0][0] / 1000000) : 0; |
|
105 | 104 | $currency = $scriptDataPrice[0][2][0][0][0][1][0][1]; |
106 | 105 | $priceText = $scriptDataPrice[0][2][0][0][0][1][0][2] ?: 'Free'; |
107 | 106 | $offersIAPCost = $scriptDataInfo[0][12][12][0] ?? null; |
108 | - $adSupported = (bool)$scriptDataInfo[0][12][14][0]; |
|
107 | + $adSupported = (bool) $scriptDataInfo[0][12][14][0]; |
|
109 | 108 | |
110 | 109 | [$size, $appVersion, $androidVersion] = $scriptDataVersion; |
111 | 110 | if (LocaleHelper::isDependOnDevice($locale, $size)) { |
@@ -208,7 +207,7 @@ discard block |
||
208 | 207 | */ |
209 | 208 | private function extractDeveloper(array $scriptDataInfo): Developer |
210 | 209 | { |
211 | - $developerPage = GPlayApps::GOOGLE_PLAY_URL . $scriptDataInfo[0][12][5][5][4][2]; |
|
210 | + $developerPage = GPlayApps::GOOGLE_PLAY_URL.$scriptDataInfo[0][12][5][5][4][2]; |
|
212 | 211 | $developerId = parse_query(parse_url($developerPage, PHP_URL_QUERY))[GPlayApps::REQ_PARAM_ID]; |
213 | 212 | $developerName = $scriptDataInfo[0][12][5][1]; |
214 | 213 | $developerEmail = $scriptDataInfo[0][12][5][2][0]; |
@@ -234,8 +233,8 @@ discard block |
||
234 | 233 | private function extractCategory(array $data): ?Category |
235 | 234 | { |
236 | 235 | if (isset($data[0]) && $data[0] !== null && $data[2] !== null) { |
237 | - $genreId = (string)$data[2]; |
|
238 | - $genreName = (string)$data[0]; |
|
236 | + $genreId = (string) $data[2]; |
|
237 | + $genreName = (string) $data[0]; |
|
239 | 238 | return new Category($genreId, $genreName); |
240 | 239 | } |
241 | 240 | return null; |
@@ -247,7 +246,7 @@ discard block |
||
247 | 246 | */ |
248 | 247 | private function extractScreenshots(array $scriptDataInfo): array |
249 | 248 | { |
250 | - return !empty($scriptDataInfo[0][12][0]) ? array_map(static function (array $v) { |
|
249 | + return !empty($scriptDataInfo[0][12][0]) ? array_map(static function(array $v) { |
|
251 | 250 | return new GoogleImage($v[3][2]); |
252 | 251 | }, $scriptDataInfo[0][12][0]) : []; |
253 | 252 | } |
@@ -263,8 +262,8 @@ discard block |
||
263 | 262 | $scriptDataInfo[0][12][3][0][3][2] !== null && |
264 | 263 | $scriptDataInfo[0][12][3][1][3][2] !== null |
265 | 264 | ) { |
266 | - $videoThumb = (string)$scriptDataInfo[0][12][3][1][3][2]; |
|
267 | - $videoUrl = (string)$scriptDataInfo[0][12][3][0][3][2]; |
|
265 | + $videoThumb = (string) $scriptDataInfo[0][12][3][1][3][2]; |
|
266 | + $videoUrl = (string) $scriptDataInfo[0][12][3][0][3][2]; |
|
268 | 267 | |
269 | 268 | return new Video($videoThumb, $videoUrl); |
270 | 269 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * @param array $scriptDataInfo |
276 | 276 | * @param string $locale |
277 | - * @return \DateTimeInterface|null |
|
277 | + * @return null|\DateTimeImmutable |
|
278 | 278 | */ |
279 | 279 | private function extractReleaseDate(array $scriptDataInfo, string $locale): ?\DateTimeInterface |
280 | 280 | { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | /** |
288 | 288 | * @param array $scriptDataInfo |
289 | - * @return \DateTimeInterface|null |
|
289 | + * @return \DateTimeImmutable|null |
|
290 | 290 | */ |
291 | 291 | private function extractUpdatedDate(array $scriptDataInfo): ?\DateTimeInterface |
292 | 292 | { |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | $dateTime = \DateTimeImmutable::createFromFormat( |
1186 | 1186 | 'Y.m.d', |
1187 | - $year . '.' . $month . '.' . $day, |
|
1187 | + $year.'.'.$month.'.'.$day, |
|
1188 | 1188 | new \DateTimeZone('UTC') |
1189 | 1189 | ); |
1190 | 1190 | if ($dateTime !== false) { |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | { |
1203 | 1203 | $dateTime = \DateTimeImmutable::createFromFormat( |
1204 | 1204 | 'U', |
1205 | - (string)$unixTime, |
|
1205 | + (string) $unixTime, |
|
1206 | 1206 | new \DateTimeZone('UTC') |
1207 | 1207 | ); |
1208 | 1208 | return $dateTime === false ? null : $dateTime; |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | * |
1159 | 1159 | * @param string $locale locale |
1160 | 1160 | * @param string $dateText localized date |
1161 | - * @return \DateTimeInterface|null returns \DateTimeInterface or null if error |
|
1161 | + * @return null|\DateTimeImmutable returns \DateTimeInterface or null if error |
|
1162 | 1162 | */ |
1163 | 1163 | public static function formatted(string $locale, string $dateText): ?\DateTimeInterface |
1164 | 1164 | { |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | |
1197 | 1197 | /** |
1198 | 1198 | * @param string|int $unixTime |
1199 | - * @return \DateTimeInterface|null |
|
1199 | + * @return \DateTimeImmutable |
|
1200 | 1200 | */ |
1201 | 1201 | public static function unixTimeToDateTime($unixTime): ?\DateTimeInterface |
1202 | 1202 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getUrl(): string |
72 | 72 | { |
73 | - return GPlayApps::GOOGLE_PLAY_APPS_URL . '/details?' . http_build_query([ |
|
73 | + return GPlayApps::GOOGLE_PLAY_APPS_URL.'/details?'.http_build_query([ |
|
74 | 74 | GPlayApps::REQ_PARAM_ID => $this->id, |
75 | 75 | ]); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getFullUrl(): string |
82 | 82 | { |
83 | - return GPlayApps::GOOGLE_PLAY_APPS_URL . '/details?' . http_build_query([ |
|
83 | + return GPlayApps::GOOGLE_PLAY_APPS_URL.'/details?'.http_build_query([ |
|
84 | 84 | GPlayApps::REQ_PARAM_ID => $this->id, |
85 | 85 | GPlayApps::REQ_PARAM_LOCALE => $this->locale, |
86 | 86 | GPlayApps::REQ_PARAM_COUNTRY => $this->country, |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | 'soc-platform' => 1, |
37 | 37 | 'soc-device' => 1, |
38 | 38 | ]; |
39 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); |
|
39 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); |
|
40 | 40 | $formParams = [ |
41 | - 'f.req' => '[[["' . self::RPC_ID_REVIEWS . '","[null,null,[2,' . $sort->value() . ',[' . $limit . ',null,' . ($token === null ? 'null' : '\\"' . $token . '\\"') . ']],[\\"' . $requestApp->getId() . '\\",7]]",null,"generic"]]]', |
|
41 | + 'f.req' => '[[["'.self::RPC_ID_REVIEWS.'","[null,null,[2,'.$sort->value().',['.$limit.',null,'.($token === null ? 'null' : '\\"'.$token.'\\"').']],[\\"'.$requestApp->getId().'\\",7]]",null,"generic"]]]', |
|
42 | 42 | ]; |
43 | 43 | $headers = [ |
44 | 44 | 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | 'soc-platform' => 1, |
66 | 66 | 'soc-device' => 1, |
67 | 67 | ]; |
68 | - $url = GPlayApps::GOOGLE_PLAY_URL . '/_/PlayStoreUi/data/batchexecute?' . http_build_query($queryParams); |
|
68 | + $url = GPlayApps::GOOGLE_PLAY_URL.'/_/PlayStoreUi/data/batchexecute?'.http_build_query($queryParams); |
|
69 | 69 | $formParams = [ |
70 | - 'f.req' => '[[["' . self::RPC_ID_APPS . '","[[null,[[10,[10,' . $limit . ']],true,null,[1]],null,\\"' . $token . '\\"]]",null,"generic"]]]', |
|
70 | + 'f.req' => '[[["'.self::RPC_ID_APPS.'","[[null,[[10,[10,'.$limit.']],true,null,[1]],null,\\"'.$token.'\\"]]",null,"generic"]]]', |
|
71 | 71 | ]; |
72 | 72 | $headers = [ |
73 | 73 | 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', |
@@ -12,7 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * @param RequestInterface $request |
14 | 14 | * @param ResponseInterface $response |
15 | - * @return mixed |
|
15 | + * @return boolean |
|
16 | 16 | */ |
17 | 17 | public function __invoke(RequestInterface $request, ResponseInterface $response) |
18 | 18 | { |