Passed
Push — feature/add-get-headers-featur... ( 3aee36 )
by Darío
07:28
created

ClientRequest::setJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace EasyHttp\LayerContracts\Tests\Unit\Example;
4
5
use EasyHttp\LayerContracts\Contracts\HttpClientRequest;
6
7
class ClientRequest implements HttpClientRequest
8
{
9
    protected string $method;
10
    protected string $uri;
11
    protected array $json;
12
    protected array $query;
13
    protected array $headers;
14
    protected bool $ssl;
15
    protected array $options;
16
17
    public function getMethod(): string
18
    {
19
        return $this->method ?? '';
20
    }
21
22
    public function getUri(): string
23
    {
24
        return $this->uri ?? '';
25
    }
26
27
    public function getJson(): array
28
    {
29
        return $this->json ?? [];
30
    }
31
32
    public function getQuery(): array
33
    {
34
        return $this->query ?? [];
35
    }
36
37
    public function getHeader(string $key)
38
    {
39
        return $this->headers[$key] ?? '';
40
    }
41
42
    public function getHeaders(): array
43
    {
44
        return $this->headers;
45
    }
46
47
    public function setMethod(string $method): HttpClientRequest
48
    {
49
        $this->method = $method;
50
51
        return $this;
52
    }
53
54
    public function setUri(string $uri): HttpClientRequest
55
    {
56
        $this->uri = $uri;
57
58
        return $this;
59
    }
60
61
    public function setHeader(string $key, string $value): HttpClientRequest
62
    {
63
        $this->headers[$key] = $value;
64
65
        return $this;
66
    }
67
68
    public function setJson(array $json): HttpClientRequest
69
    {
70
        $this->json = $json;
71
72
        return $this;
73
    }
74
75
    public function setQuery(array $query): HttpClientRequest
76
    {
77
        $this->query = $query;
78
79
        return $this;
80
    }
81
82
    public function ssl(bool $ssl): void
83
    {
84
        $this->ssl = $ssl;
85
    }
86
}
87