DummyMethod   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 3 1
A getMethodUrl() 0 3 1
A getHttpMethod() 0 3 1
A processResponse() 0 3 1
A getHost() 0 3 1
A handleException() 0 3 1
A getScheme() 0 3 1
A getQueryParameters() 0 3 1
A __construct() 0 3 1
A getBody() 0 3 1
A getOptions() 0 3 1
1
<?php
2
3
namespace TheHorhe\ApiClient\Example;
4
5
use Psr\Http\Message\ResponseInterface;
6
use TheHorhe\ApiClient\MethodInterface;
7
8
/**
9
 * If you are lazy to create infrastructure.
10
 * All configurable method parameters just passed as array.
11
 * Recommended for test purposes only.
12
 */
13
class DummyMethod implements MethodInterface
14
{
15
16
    protected $parameters;
17
18
    public function __construct(array $parameters)
19
    {
20
        $this->parameters = $parameters;
21
    }
22
23
    public function getHeaders()
24
    {
25
        return $this->parameters['headers'] ?? [];
26
    }
27
28
    public function getQueryParameters()
29
    {
30
        return $this->parameters['query_parameters'] ?? [];
31
    }
32
33
    public function getHttpMethod()
34
    {
35
        return $this->parameters['http_method'] ?? 'POST';
36
    }
37
38
    public function getScheme()
39
    {
40
        return $this->parameters['scheme'] ?? 'https';
41
    }
42
43
    public function getHost()
44
    {
45
        return $this->parameters['host'] ?? '';
46
    }
47
48
    public function getMethodUrl()
49
    {
50
        return $this->parameters['method_url'] ?? '';
51
    }
52
53
    public function processResponse(ResponseInterface $response)
54
    {
55
        return $response;
56
    }
57
58
    public function handleException(\Throwable $exception)
59
    {
60
        throw $exception;
61
    }
62
63
    public function getBody()
64
    {
65
        return $this->parameters['body'] ?? null;
66
    }
67
68
    public function getOptions()
69
    {
70
        return $this->parameters['options'] ?? null;
71
    }
72
73
}