Completed
Push — master ( 05544f...34252d )
by Maxime
02:24
created

AbstractHttpMessage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 63
ccs 14
cts 14
cp 1
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 getHttpVersion() 0 4 1
A getHeaders() 0 4 1
A getHeader() 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 10
    protected function setHttpVersion($httpVersion)
31
    {
32 10
        $this->httpVersion = $httpVersion;
33
34 10
        return $this;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @param string $value
40
     * @return Request
41
     */
42 9
    public function addHeader(string $name, string $value)
43
    {
44 9
        if (null === $this->headers) {
45 9
            $this->headers = new HttpHeadersBag();
46
        }
47 9
        $this->headers->add($name, $value);
48
49 9
        return $this;
50
    }
51
52
    /**
53
     * @param string $header
54
     * @return string
55
     */
56 3
    public function getHeader($header)
57
    {
58 3
        return $this->headers[$header];
59
    }
60
61
    /**
62
     * @return string
63
     */
64 8
    public function getHttpVersion()
65
    {
66 8
        return $this->httpVersion;
67
    }
68
69
    /**
70
     * @return array|HttpHeadersBag
71
     */
72 9
    public function getHeaders()
73
    {
74 9
        return $this->headers;
75
    }
76
}
77