GetImages::processResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace TheHorhe\ApiClient\Example\Cats\Method;
4
5
use Psr\Http\Message\ResponseInterface;
6
use TheHorhe\ApiClient\AbstractApiMethod;
7
use TheHorhe\ApiClient\Example\Cats\Exception\CatException;
8
use TheHorhe\ApiClient\MethodInterface;
9
10
class GetImages extends AbstractApiMethod
11
{
12
    protected $resultsPerPage = 10;
13
14
    /**
15
     * GetImages constructor.
16
     * @param int $resultsPerPage
17
     */
18
    public function __construct($resultsPerPage)
19
    {
20
        $this->resultsPerPage = $resultsPerPage;
21
    }
22
23
    public function getHeaders()
24
    {
25
        return [];
26
    }
27
28
    public function getQueryParameters()
29
    {
30
        return [
31
            'format' => 'xml',
32
            'results_per_page' => $this->resultsPerPage
33
        ];
34
    }
35
36
    public function getHttpMethod()
37
    {
38
        return 'GET';
39
    }
40
41
    public function getScheme()
42
    {
43
        return 'https';
44
    }
45
46
    public function getHost()
47
    {
48
        return 'thecatapi.com';
49
    }
50
51
    public function getMethodUrl()
52
    {
53
        return '/api/images/get';
54
    }
55
56
    public function processResponse(ResponseInterface $response)
57
    {
58
        return $response->getBody()->getContents();
59
    }
60
61
    public function handleException(\Throwable $exception)
62
    {
63
        throw new CatException($exception->getMessage(), $exception->getCode(), $exception);
64
    }
65
66
}