Completed
Push — master ( 45165d...5e44c4 )
by Alexey
04:08 queued 11s
created

SuggestScraper::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nelexa\GPlay\Scraper;
6
7
use Nelexa\HttpClient\ResponseHandlerInterface;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
/**
12
 * @internal
13
 */
14
class SuggestScraper implements ResponseHandlerInterface
15
{
16
    /**
17
     * @param RequestInterface  $request
18
     * @param ResponseInterface $response
19
     *
20
     * @return mixed
21
     */
22 1
    public function __invoke(RequestInterface $request, ResponseInterface $response)
23
    {
24 1
        $json = \GuzzleHttp\json_decode($response->getBody()->getContents(), true);
25
26 1
        return array_map(
27
            static function (array $v) {
28 1
                return $v['s'];
29 1
            },
30
            $json
31
        );
32
    }
33
}
34