summaryrefslogtreecommitdiff
path: root/inc/mailgun/php-http/message/src/Authentication/Bearer.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/mailgun/php-http/message/src/Authentication/Bearer.php')
-rw-r--r--inc/mailgun/php-http/message/src/Authentication/Bearer.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/inc/mailgun/php-http/message/src/Authentication/Bearer.php b/inc/mailgun/php-http/message/src/Authentication/Bearer.php
new file mode 100644
index 0000000..a8fb21a
--- /dev/null
+++ b/inc/mailgun/php-http/message/src/Authentication/Bearer.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Http\Message\Authentication;
+
+use Http\Message\Authentication;
+use Psr\Http\Message\RequestInterface;
+
+/**
+ * Authenticate a PSR-7 Request using a token.
+ *
+ * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
+ */
+final class Bearer implements Authentication
+{
+ /**
+ * @var string
+ */
+ private $token;
+
+ /**
+ * @param string $token
+ */
+ public function __construct($token)
+ {
+ $this->token = $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function authenticate(RequestInterface $request)
+ {
+ $header = sprintf('Bearer %s', $this->token);
+
+ return $request->withHeader('Authorization', $header);
+ }
+}