Completed
Push — master ( 84ca4a...202c6b )
by Andy
02:06 queued 42s
created

Request::getHeaderStrings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
ccs 5
cts 5
cp 1
crap 2
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 2
    public function addHeader(string $key, string $value): self
13
    {
14 2
        $this->headers[$key] = $value;
15
16 2
        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 5
    public function getHeaders(): array
31
    {
32 5
        return $this->headers;
33
    }
34
35 5
    public function getHeaderStrings(): array
36
    {
37 5
        $headers = [];
38 5
        foreach ($this->getHeaders() as $key => $value) {
39 2
            $headers[] = "$key: $value";
40
        }
41
42 5
        return $headers;
43
    }
44
45
    /**
46
     * @param string|array $body
47
     */
48 2
    public function setBody($body): self
49
    {
50 2
        $this->body = $body;
51
52 2
        return $this;
53
    }
54
55
    /**
56
     * @return array|string
57
     */
58 4
    public function getBody()
59
    {
60 4
        return $this->body;
61
    }
62
}
63