-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBlueskyTransportFactory.php
57 lines (48 loc) · 1.73 KB
/
BlueskyTransportFactory.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
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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\Bluesky;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
final class BlueskyTransportFactory extends AbstractTransportFactory
{
public function __construct(
?EventDispatcherInterface $dispatcher = null,
?HttpClientInterface $client = null,
private ?LoggerInterface $logger = null,
private readonly ?ClockInterface $clock = null,
) {
parent::__construct($dispatcher, $client);
}
public function create(Dsn $dsn): BlueskyTransport
{
$scheme = $dsn->getScheme();
if ('bluesky' !== $scheme) {
throw new UnsupportedSchemeException($dsn, 'bluesky', $this->getSupportedSchemes());
}
$user = $this->getUser($dsn);
$secret = $this->getPassword($dsn);
return (new BlueskyTransport($user, $secret, $this->logger ?? new NullLogger(), $this->client, $this->dispatcher, $this->clock))
->setHost($dsn->getHost())
->setPort($dsn->getPort());
}
protected function getSupportedSchemes(): array
{
return ['bluesky'];
}
}