Test Failed
Push — master ( dc41f6...84ca4a )
by Andy
01:30
created

Request   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 56
ccs 15
cts 20
cp 0.75
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 3 1
A addHeader() 0 5 1
A setHeaders() 0 9 2
A getHeaderStrings() 0 8 2
A setBody() 0 5 1
A getBody() 0 3 1
1
<?php
2
3
namespace Palmtree\Curl;
4
5
class Request
6
{
7
    /** @var array */
8
    private $headers = [];
9
    /** @var array|string */
10
    private $body;
11
12 1
    public function addHeader(string $key, string $value): self
13
    {
14 1
        $this->headers[$key] = $value;
15
16 1
        return $this;
17
    }
18
19 1
    public function setHeaders(array $headers): self
20
    {
21 1
        $this->headers = [];
22
23 1
        foreach ($headers as $key => $value) {
24 1
            $this->addHeader($key, $value);
25
        }
26
27 1
        return $this;
28
    }
29
30 1
    public function getHeaders(): array
31
    {
32 1
        return $this->headers;
33
    }
34
35 1
    public function getHeaderStrings(): array
36
    {
37 1
        $headers = [];
38 1
        foreach ($this->getHeaders() as $key => $value) {
39 1
            $headers[] = "$key: $value";
40
        }
41
42 1
        return $headers;
43
    }
44
45
    /**
46
     * @param string|array $body
47
     */
48
    public function setBody($body): self
49
    {
50
        $this->body = $body;
51
52
        return $this;
53
    }
54
55
    /**
56
     * @return array|string
57
     */
58
    public function getBody()
59
    {
60
        return $this->body;
61
    }
62
}
63