/
AllMySMSTransportFactory.php
44 lines (37 loc) · 1.35 KB
/
AllMySMSTransportFactory.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
37
38
39
40
41
42
43
44
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Notifier\Bridge\AllMySMS;
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;
use Symfony\Component\Notifier\Transport\TransportInterface;
/**
* @author Quentin Dequippe <quentin@dequippe.tech>
*/
final class AllMySMSTransportFactory extends AbstractTransportFactory
{
public function create(Dsn $dsn): TransportInterface
{
$scheme = $dsn->getScheme();
$login = $this->getUser($dsn);
$apiKey = $this->getPassword($dsn);
$tpoa = $dsn->getOption('tpoa');
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
$port = $dsn->getPort();
if ('allmysms' === $scheme) {
return (new AllMySMSTransport($login, $apiKey, $this->client, $tpoa, $this->dispatcher))->setHost($host)->setPort($port);
}
throw new UnsupportedSchemeException($dsn, 'allmysms', $this->getSupportedSchemes());
}
protected function getSupportedSchemes(): array
{
return ['allmysms'];
}
}