Completed
Pull Request — master (#1)
by Márk
01:55
created

MessageDecorator::hasHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Http\Message\Decorator;
4
5
use Psr\Http\Message\MessageInterface;
6
use Psr\Http\Message\StreamInterface;
7
8
/**
9
 * @author Márk Sági-Kazár <[email protected]>
10
 */
11
trait MessageDecorator
12
{
13
    /**
14
     * @var MessageInterface
15
     */
16
    private $message;
17
18
    /**
19
     * Returns the decorated message.
20
     *
21
     * Since the underlying Message is immutable as well
22
     * exposing it is not an issue, because it's state cannot be altered
23
     *
24
     * @return MessageInterface
25
     */
26 14
    public function getMessage()
27
    {
28 14
        return $this->message;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function getProtocolVersion()
35
    {
36 1
        return $this->message->getProtocolVersion();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function withProtocolVersion($version)
43
    {
44 1
        $new = clone $this;
45 1
        $new->message = $this->message->withProtocolVersion($version);
46
47 1
        return $new;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    public function getHeaders()
54
    {
55 1
        return $this->message->getHeaders();
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 1
    public function hasHeader($header)
62
    {
63 1
        return $this->message->hasHeader($header);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 1
    public function getHeader($header)
70
    {
71 1
        return $this->message->getHeader($header);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 1
    public function getHeaderLine($header)
78
    {
79 1
        return $this->message->getHeaderLine($header);
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 1
    public function withHeader($header, $value)
86
    {
87 1
        $new = clone $this;
88 1
        $new->message = $this->message->withHeader($header, $value);
89
90 1
        return $new;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96 1
    public function withAddedHeader($header, $value)
97
    {
98 1
        $new = clone $this;
99 1
        $new->message = $this->message->withAddedHeader($header, $value);
100
101 1
        return $new;
102
    }
103
104
    /**
105
     * {@inheritdoc}
106
     */
107 1
    public function withoutHeader($header)
108
    {
109 1
        $new = clone $this;
110 1
        $new->message = $this->message->withoutHeader($header);
111
112 1
        return $new;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118 1
    public function getBody()
119
    {
120 1
        return $this->message->getBody();
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126 1
    public function withBody(StreamInterface $body)
127
    {
128 1
        $new = clone $this;
129 1
        $new->message = $this->message->withBody($body);
130
131 1
        return $new;
132
    }
133
}
134