1 <?php
2
3 namespace Http\Message\Decorator;
4
5 use Psr\Http\Message\MessageInterface;
6 use Psr\Http\Message\StreamInterface;
7
8 9 10
11 trait MessageDecorator
12 {
13 14 15
16 private $message;
17
18 19 20 21 22 23 24 25
26 public function getMessage()
27 {
28 return $this->message;
29 }
30
31 32 33
34 public function getProtocolVersion()
35 {
36 return $this->message->getProtocolVersion();
37 }
38
39 40 41
42 public function withProtocolVersion($version)
43 {
44 $new = clone $this;
45 $new->message = $this->message->withProtocolVersion($version);
46
47 return $new;
48 }
49
50 51 52
53 public function getHeaders()
54 {
55 return $this->message->getHeaders();
56 }
57
58 59 60
61 public function hasHeader($header)
62 {
63 return $this->message->hasHeader($header);
64 }
65
66 67 68
69 public function getHeader($header)
70 {
71 return $this->message->getHeader($header);
72 }
73
74 75 76
77 public function getHeaderLine($header)
78 {
79 return $this->message->getHeaderLine($header);
80 }
81
82 83 84
85 public function withHeader($header, $value)
86 {
87 $new = clone $this;
88 $new->message = $this->message->withHeader($header, $value);
89
90 return $new;
91 }
92
93 94 95
96 public function withAddedHeader($header, $value)
97 {
98 $new = clone $this;
99 $new->message = $this->message->withAddedHeader($header, $value);
100
101 return $new;
102 }
103
104 105 106
107 public function withoutHeader($header)
108 {
109 $new = clone $this;
110 $new->message = $this->message->withoutHeader($header);
111
112 return $new;
113 }
114
115 116 117
118 public function getBody()
119 {
120 return $this->message->getBody();
121 }
122
123 124 125
126 public function withBody(StreamInterface $body)
127 {
128 $new = clone $this;
129 $new->message = $this->message->withBody($body);
130
131 return $new;
132 }
133 }
134