-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoveTransportFactory.php
36 lines (28 loc) · 1.08 KB
/
GoveTransportFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Mangati\Notifier\Gove;
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;
use Symfony\Component\Notifier\Transport\TransportInterface;
final class GoveTransportFactory extends AbstractTransportFactory
{
private const SCHEME = 'gove';
/** @return GoveTransport */
public function create(Dsn $dsn): TransportInterface
{
$scheme = $dsn->getScheme();
if (self::SCHEME !== $scheme) {
throw new UnsupportedSchemeException($dsn, self::SCHEME, $this->getSupportedSchemes());
}
$email = $this->getUser($dsn);
$password = $this->getPassword($dsn);
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
$port = $dsn->getPort();
return (new GoveTransport($email, $password, $this->client, $this->dispatcher))
->setHost($host)->setPort($port);
}
protected function getSupportedSchemes(): array
{
return [self::SCHEME];
}
}