Passed
Push — master ( 81593c...33129c )
by Alexey
10:12 queued 12s
created

FindDevAppsUrlScraper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 21
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 2
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\Util\ScraperUtil;
19
use Psr\Http\Message\RequestInterface;
20
use Psr\Http\Message\ResponseInterface;
21
22
/**
23
 * @internal
24
 */
25
class FindDevAppsUrlScraper implements ParseHandlerInterface
26
{
27
    /**
28
     * @param RequestInterface  $request
29
     * @param ResponseInterface $response
30
     * @param array             $options
31
     *
32
     * @throws \Nelexa\GPlay\Exception\GooglePlayException
33
     *
34
     * @return string|null
35
     */
36 1
    public function __invoke(RequestInterface $request, ResponseInterface $response, array &$options = []): ?string
37
    {
38 1
        $scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents());
39 1
        $scriptDataAppsUrl = ScraperUtil::getValue($scriptData, 'ds:3.0.1.0.21.1.2.4.2');
40
41 1
        if (\is_string($scriptDataAppsUrl)) {
42 1
            return GPlayApps::GOOGLE_PLAY_URL . $scriptDataAppsUrl;
43
        }
44
45
        return null;
46
    }
47
}
48