summaryrefslogtreecommitdiff
path: root/inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2017-03-02 22:49:24 -0500
committerCarson Fleming <cflems@cflems.net>2017-03-02 22:49:24 -0500
commitb76e2ff898b23745d4c9aaee49eeb7d88f2896ab (patch)
tree9b794be8db310a575d70165d9ebde0a183b61b01 /inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php
parentbfcc9f7a7656a2db0c905b3c13114664f00f6c37 (diff)
downloadbulletin-b76e2ff898b23745d4c9aaee49eeb7d88f2896ab.tar.gz
Updated mailgun plugin
Diffstat (limited to 'inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php')
-rw-r--r--inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php b/inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php
new file mode 100644
index 0000000..cdad2ec
--- /dev/null
+++ b/inc/mailgun/php-http/message/src/MessageFactory/SlimMessageFactory.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Http\Message\MessageFactory;
+
+use Http\Message\StreamFactory\SlimStreamFactory;
+use Http\Message\UriFactory\SlimUriFactory;
+use Http\Message\MessageFactory;
+use Slim\Http\Request;
+use Slim\Http\Response;
+use Slim\Http\Headers;
+
+/**
+ * Creates Slim 3 messages.
+ *
+ * @author Mika Tuupola <tuupola@appelsiini.net>
+ */
+final class SlimMessageFactory implements MessageFactory
+{
+ /**
+ * @var SlimStreamFactory
+ */
+ private $streamFactory;
+
+ /**
+ * @var SlimUriFactory
+ */
+ private $uriFactory;
+
+ public function __construct()
+ {
+ $this->streamFactory = new SlimStreamFactory();
+ $this->uriFactory = new SlimUriFactory();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function createRequest(
+ $method,
+ $uri,
+ array $headers = [],
+ $body = null,
+ $protocolVersion = '1.1'
+ ) {
+ return (new Request(
+ $method,
+ $this->uriFactory->createUri($uri),
+ new Headers($headers),
+ [],
+ [],
+ $this->streamFactory->createStream($body),
+ []
+ ))->withProtocolVersion($protocolVersion);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function createResponse(
+ $statusCode = 200,
+ $reasonPhrase = null,
+ array $headers = [],
+ $body = null,
+ $protocolVersion = '1.1'
+ ) {
+ return (new Response(
+ $statusCode,
+ new Headers($headers),
+ $this->streamFactory->createStream($body)
+ ))->withProtocolVersion($protocolVersion);
+ }
+}