| Conditions | 5 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.3073 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 1 | public function __invoke(RequestInterface $request, ResponseInterface $response): ?string |
|
| 35 | { |
||
| 36 | 1 | $scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents()); |
|
| 37 | |||
| 38 | 1 | $scriptDataApps = null; |
|
| 39 | |||
| 40 | 1 | foreach ($scriptData as $key => $scriptValue) { |
|
| 41 | 1 | if (isset($scriptValue[0][1][0][0][3][4][2])) { // ds:3 |
|
| 42 | 1 | $scriptDataApps = $scriptValue; |
|
| 43 | 1 | break; |
|
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | if ($scriptDataApps === null) { |
|
| 48 | throw (new GooglePlayException('Error fetch cluster page')) |
||
| 49 | ->setUrl($request->getUri()->__toString()) |
||
| 50 | ; |
||
| 51 | } |
||
| 52 | |||
| 53 | 1 | if (isset($scriptDataApps[0][1][0][0][3][4][2])) { |
|
| 54 | 1 | return GPlayApps::GOOGLE_PLAY_URL . $scriptDataApps[0][1][0][0][3][4][2]; |
|
| 55 | } |
||
| 56 | |||
| 57 | return null; |
||
| 58 | } |
||
| 60 |