Request   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 56
ccs 18
cts 20
cp 0.9
rs 10
wmc 8

6 Methods

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