GetImages   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 13
dl 0
loc 54
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A processResponse() 0 3 1
A handleException() 0 3 1
A getHttpMethod() 0 3 1
A getScheme() 0 3 1
A __construct() 0 3 1
A getHeaders() 0 3 1
A getHost() 0 3 1
A getMethodUrl() 0 3 1
A getQueryParameters() 0 5 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
}