From b76e2ff898b23745d4c9aaee49eeb7d88f2896ab Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 2 Mar 2017 22:49:24 -0500 Subject: Updated mailgun plugin --- .../message/src/Authentication/BasicAuth.php | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 inc/mailgun/php-http/message/src/Authentication/BasicAuth.php (limited to 'inc/mailgun/php-http/message/src/Authentication/BasicAuth.php') diff --git a/inc/mailgun/php-http/message/src/Authentication/BasicAuth.php b/inc/mailgun/php-http/message/src/Authentication/BasicAuth.php new file mode 100644 index 0000000..23618a5 --- /dev/null +++ b/inc/mailgun/php-http/message/src/Authentication/BasicAuth.php @@ -0,0 +1,44 @@ + + */ +final class BasicAuth implements Authentication +{ + /** + * @var string + */ + private $username; + + /** + * @var string + */ + private $password; + + /** + * @param string $username + * @param string $password + */ + public function __construct($username, $password) + { + $this->username = $username; + $this->password = $password; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password))); + + return $request->withHeader('Authorization', $header); + } +} -- cgit v1.2.3