Conditions | 6 |
Paths | 9 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function __invoke(RequestInterface $request, ResponseInterface $response): array |
||
22 | { |
||
23 | $scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents()); |
||
24 | $scriptDataInfo = null; |
||
25 | foreach ($scriptData as $scriptValue) { |
||
26 | if (isset($scriptValue[0][1][0][0][0]) && is_array($scriptValue[0][1][0][0][0])) { |
||
27 | $scriptDataInfo = $scriptValue; // ds:3 |
||
28 | break; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | if ($scriptDataInfo === null) { |
||
33 | return [[], null]; |
||
34 | } |
||
35 | |||
36 | $locale = parse_query($request->getUri()->getQuery())[GPlayApps::REQ_PARAM_LOCALE] ?? GPlayApps::DEFAULT_LOCALE; |
||
37 | |||
38 | $apps = []; |
||
39 | foreach ($scriptDataInfo[0][1][0][0][0] as $data) { |
||
40 | $apps[] = AppsExtractor::extractApp($data, $locale); |
||
41 | } |
||
42 | |||
43 | $nextToken = $scriptDataInfo[0][1][0][0][7][1] ?? null; |
||
44 | return [$apps, $nextToken]; |
||
45 | } |
||
47 |