/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransportFactory.php
50 строк
2 KB
Nicolas Grekas
Remove full DSNs from exception messages
23 янв 2023, 17:48
23 янв 2023, 17:48
1cbd95e
Код
Авторство
О чём код?
<?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\Twitter; use Symfony\Component\Notifier\Exception\IncompleteDsnException; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; use Symfony\Component\Notifier\Transport\AbstractTransportFactory; use Symfony\Component\Notifier\Transport\Dsn; /** * @author Nicolas Grekas <p@tchwork.com> */ final class TwitterTransportFactory extends AbstractTransportFactory { public function create(Dsn $dsn): TwitterTransport { $scheme = $dsn->getScheme(); if ('twitter' !== $scheme) { throw new UnsupportedSchemeException($dsn, 'twitter', $this->getSupportedSchemes()); } $apiKey = $this->getUser($dsn); [$apiSecret, $accessToken, $accessSecret] = explode(':', $this->getPassword($dsn)) + [1 => null, null, null]; foreach (['API Key' => $apiKey, 'API Key Secret' => $apiSecret, 'Access Token' => $accessToken, 'Access Token Secret' => $accessSecret] as $name => $key) { if (!$key) { throw new IncompleteDsnException($name.' is missing.', 'twitter://'.$dsn->getHost()); } } return (new TwitterTransport($apiKey, $apiSecret, $accessToken, $accessSecret, $this->client, $this->dispatcher)) ->setHost('default' === $dsn->getHost() ? null : $dsn->getHost()) ->setPort($dsn->getPort()); } protected function getSupportedSchemes(): array { return ['twitter']; } }