summaryrefslogtreecommitdiffstats
path: root/library/vendor/iplx/Http/Response.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/vendor/iplx/Http/Response.php')
-rw-r--r--library/vendor/iplx/Http/Response.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/library/vendor/iplx/Http/Response.php b/library/vendor/iplx/Http/Response.php
new file mode 100644
index 0000000..25448b1
--- /dev/null
+++ b/library/vendor/iplx/Http/Response.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace iplx\Http;
+
+use Psr\Http\Message\ResponseInterface;
+
+/**
+ * A HTTP response
+ */
+class Response implements ResponseInterface
+{
+ use MessageTrait;
+
+ /**
+ * Status code of the response
+ *
+ * @var int
+ */
+ protected $statusCode;
+
+ /**
+ * Response status reason phrase
+ *
+ * @var string
+ */
+ protected $reasonPhrase = '';
+
+ /**
+ * Create a new HTTP response
+ *
+ * @param int $statusCode Response status code
+ * @param array $headers Response headers
+ * @param string $body Response body
+ * @param string $protocolVersion Protocol version
+ * @param string $reasonPhrase Response status reason phrase
+ */
+ public function __construct($statusCode = 200, array $headers = [], $body = null, $protocolVersion = '1.1', $reasonPhrase = '')
+ {
+ $this->statusCode = $statusCode;
+ $this->setHeaders($headers);
+ $this->body = Stream::create($body);
+ $this->protocolVersion = $protocolVersion;
+ $this->reasonPhrase = $reasonPhrase;
+ }
+
+ public function getStatusCode()
+ {
+ return $this->statusCode;
+ }
+
+ public function withStatus($code, $reasonPhrase = '')
+ {
+ $response = clone $this;
+ $response->statusCode = $code;
+ $response->reasonPhrase = $reasonPhrase;
+
+ return $response;
+ }
+
+ public function getReasonPhrase()
+ {
+ return $this->reasonPhrase;
+ }
+}