1616 */
1717class Message implements MessageInterface
1818{
19- const DEFAULT_HTTP_VERSION = '1.1 ' ;
19+ protected const DEFAULT_HTTP_VERSION = '1.1 ' ;
2020
2121 /**
22- * @var HttpRequest
22+ * @var HttpRequest $request
2323 */
2424 protected $ request ;
2525
2626 /**
27- * @var string
27+ * @var string $httpVersion
2828 */
2929 protected $ httpVersion ;
3030
@@ -33,15 +33,15 @@ class Message implements MessageInterface
3333 */
3434
3535 protected $ body ;
36+
3637 /**
37- * @var UriInterface
38+ * @var UriInterface $uri
3839 */
39-
4040 protected $ uri ;
41+
4142 /**
42- * @var array
43+ * @var array $attributes
4344 */
44-
4545 protected $ attributes ;
4646
4747 /**
@@ -57,7 +57,7 @@ public function __construct(
5757 string $ httpVersion = null ,
5858 $ body = null ,
5959 array $ attributes = []
60- ){
60+ ) {
6161 $ this ->request = $ request ;
6262 $ this ->httpVersion = $ httpVersion ;
6363 $ this ->body = $ body ;
@@ -73,27 +73,7 @@ public function __construct(
7373 }
7474
7575 /**
76- * @param HttpRequest $request
77- *
78- * @return boolean
79- */
80- private function needCheckBody (HttpRequest $ request )
81- {
82- $ method = strtolower ($ request ->getRequestMethod ());
83- return in_array ($ method , ['post ' , 'put ' ]);
84- }
85-
86- private function getCurrentLink ()
87- {
88- $ server = $ this ->request ->getServer ();
89- return ($ server ->get ('HTTPS ' ) === 'on ' ? "https " : "http " ).
90- ":// " .
91- $ server ->get ('HTTP_HOST ' ).
92- $ server ->get ('REQUEST_URI ' );
93- }
94-
95- /**
96- * @return string
76+ * @inheritDoc
9777 */
9878 public function getProtocolVersion ()
9979 {
@@ -105,18 +85,16 @@ public function getProtocolVersion()
10585 return $ this ->httpVersion = str_replace (['HTTP ' , '/ ' ], '' , $ version );
10686 }
10787
108-
10988 /**
110- * @param string $version
111- * @return $this|Message
89+ * @inheritDoc
11290 */
11391 public function withProtocolVersion ($ version )
11492 {
11593 return new static ($ this ->request , $ version , $ this ->body , $ this ->attributes );
11694 }
11795
11896 /**
119- * @return array|string[][]
97+ * @inheritDoc
12098 */
12199 public function getHeaders ()
122100 {
@@ -130,22 +108,23 @@ public function getHeaders()
130108 }
131109
132110 /**
133- * @param string $name
134- * @return bool
111+ * @inheritDoc
135112 */
136113 public function hasHeader ($ name )
137114 {
138115 return !empty ($ this ->getHeader ($ name ));
139116 }
140117
118+ /**
119+ * @inheritDoc
120+ */
141121 public function getHeader ($ name )
142122 {
143123 return (array )($ this ->request ->getHeader ($ name ) ?? []);
144124 }
145125
146126 /**
147- * @param string $name
148- * @return string
127+ * @inheritDoc
149128 */
150129 public function getHeaderLine ($ name )
151130 {
@@ -158,9 +137,7 @@ public function getHeaderLine($name)
158137 }
159138
160139 /**
161- * @param string $name
162- * @param string|string[] $value
163- * @return $this|Message
140+ * @inheritDoc
164141 */
165142 public function withHeader ($ name , $ value )
166143 {
@@ -170,9 +147,7 @@ public function withHeader($name, $value)
170147 }
171148
172149 /**
173- * @param string $name
174- * @param string|string[] $value
175- * @return $this|Message
150+ * @inheritDoc
176151 */
177152 public function withAddedHeader ($ name , $ value )
178153 {
@@ -187,8 +162,7 @@ public function withAddedHeader($name, $value)
187162 }
188163
189164 /**
190- * @param string $name
191- * @return $this|Message
165+ * @inheritDoc
192166 */
193167 public function withoutHeader ($ name )
194168 {
@@ -203,7 +177,7 @@ public function withoutHeader($name)
203177 }
204178
205179 /**
206- * @return StreamInterface
180+ * @inheritDoc
207181 */
208182 public function getBody ()
209183 {
@@ -215,8 +189,7 @@ public function getBody()
215189 }
216190
217191 /**
218- * @param StreamInterface $body
219- * @return $this|Message
192+ * @inheritDoc
220193 */
221194 public function withBody (StreamInterface $ body )
222195 {
@@ -226,4 +199,30 @@ public function withBody(StreamInterface $body)
226199
227200 return new static ($ this ->request , $ this ->httpVersion , $ body , $ this ->attributes );
228201 }
202+
203+ /**
204+ * @param HttpRequest $request Битриксовый Request.
205+ *
206+ * @return boolean
207+ */
208+ private function needCheckBody (HttpRequest $ request )
209+ {
210+ $ method = strtolower ($ request ->getRequestMethod ());
211+
212+ return in_array ($ method , ['post ' , 'put ' ]);
213+ }
214+
215+ /**
216+ * Текущий URL.
217+ *
218+ * @return string
219+ */
220+ private function getCurrentLink () : string
221+ {
222+ $ server = $ this ->request ->getServer ();
223+ return ($ server ->get ('HTTPS ' ) === 'on ' ? 'https ' : 'http ' ).
224+ ':// ' .
225+ $ server ->get ('HTTP_HOST ' ).
226+ $ server ->get ('REQUEST_URI ' );
227+ }
229228}
0 commit comments