Completed
Pull Request — master (#110)
by Charlotte
06:09
created

AbstractHttpMessage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 63
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setHttpVersion() 0 6 1
A addHeader() 0 9 2
A getHeader() 0 4 1
A getHttpVersion() 0 4 1
A getHeaders() 0 4 1
1
<?php
2
/**
3
 * This file is a part of a nekland library
4
 *
5
 * (c) Nekland <[email protected]>
6
 *
7
 * For the full license, take a look to the LICENSE file
8
 * on the root directory of this project
9
 */
10
11
namespace Nekland\Woketo\Http;
12
13
14
abstract class AbstractHttpMessage
15
{
16
    /**
17
     * @var HttpHeadersBag
18
     */
19
    private $headers;
20
21
    /**
22
     * @var string for example "HTTP/1.1"
23
     */
24
    private $httpVersion;
25
26
    /**
27
     * @param string $httpVersion
28
     * @return Request
29
     */
30
    protected function setHttpVersion($httpVersion)
31
    {
32
        $this->httpVersion = $httpVersion;
33
34
        return $this;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @param string $value
40
     * @return Request
41
     */
42
    public function addHeader(string $name, string $value)
43
    {
44
        if (null === $this->headers) {
45
            $this->headers = new HttpHeadersBag();
46
        }
47
        $this->headers->add($name, $value);
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param string $header
54
     * @return string
55
     */
56
    public function getHeader($header)
57
    {
58
        return $this->headers[$header];
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getHttpVersion()
65
    {
66
        return $this->httpVersion;
67
    }
68
69
    /**
70
     * @return array|HttpHeadersBag
71
     */
72
    public function getHeaders()
73
    {
74
        return $this->headers;
75
    }
76
}
77