DummyMethod::getHost()   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 0
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
}