1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /* |
||||
6 | * Copyright (c) Ne-Lexa |
||||
7 | * |
||||
8 | * For the full copyright and license information, please view |
||||
9 | * the LICENSE file that was distributed with this source code. |
||||
10 | * |
||||
11 | * @see https://github.com/Ne-Lexa/google-play-scraper |
||||
12 | */ |
||||
13 | |||||
14 | namespace Nelexa\GPlay\Scraper; |
||||
15 | |||||
16 | use Nelexa\GPlay\GPlayApps; |
||||
17 | use Nelexa\GPlay\HttpClient\ParseHandlerInterface; |
||||
18 | use Nelexa\GPlay\Model\ClusterPage; |
||||
19 | use Psr\Http\Message\RequestInterface; |
||||
20 | use Psr\Http\Message\ResponseInterface; |
||||
21 | |||||
22 | /** |
||||
23 | * @internal |
||||
24 | */ |
||||
25 | class ClusterPagesFromClusterResponseScraper implements ParseHandlerInterface |
||||
26 | { |
||||
27 | /** |
||||
28 | * @param RequestInterface $request |
||||
29 | * @param ResponseInterface $response |
||||
30 | * @param array $options |
||||
31 | * |
||||
32 | * @return string[] |
||||
33 | */ |
||||
34 | 5 | public function __invoke(RequestInterface $request, ResponseInterface $response, array &$options = []): array |
|||
35 | { |
||||
36 | 5 | $contents = substr($response->getBody()->getContents(), 5); |
|||
37 | 5 | $json = \GuzzleHttp\json_decode($contents, true); |
|||
0 ignored issues
–
show
|
|||||
38 | 5 | $json = \GuzzleHttp\json_decode($json[0][2], true); |
|||
0 ignored issues
–
show
The function
GuzzleHttp\json_decode() has been deprecated: json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
39 | |||||
40 | 5 | $results = []; |
|||
41 | 5 | if (isset($json[0][1]) && \is_array($json[0][1])) { |
|||
42 | 5 | foreach ($json[0][1] as $item) { |
|||
43 | 5 | if (isset($item[21][1][0], $item[21][1][2][4][2])) { |
|||
44 | 5 | $results[] = new ClusterPage( |
|||
45 | 5 | trim($item[21][1][0]), |
|||
46 | 5 | GPlayApps::GOOGLE_PLAY_URL . $item[21][1][2][4][2] |
|||
47 | ); |
||||
48 | 5 | } elseif (isset($item[22][1][0], $item[22][1][2][4][2])) { |
|||
49 | $results[] = new ClusterPage( |
||||
50 | trim($item[22][1][0]), |
||||
51 | GPlayApps::GOOGLE_PLAY_URL . $item[22][1][2][4][2] |
||||
52 | ); |
||||
53 | } |
||||
54 | } |
||||
55 | } |
||||
56 | 5 | $token = $json[0][3][1] ?? null; |
|||
57 | |||||
58 | return [ |
||||
0 ignored issues
–
show
|
|||||
59 | 5 | 'results' => $results, |
|||
60 | 'token' => $token, |
||||
61 | ]; |
||||
62 | } |
||||
63 | } |
||||
64 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.