NtfyTransport example

use Symfony\Component\Notifier\Tests\Transport\DummyMessage;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

/** * @author Mickael Perraud <mikaelkael.fr@gmail.com> */
final class NtfyTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): NtfyTransport
    {
        return new NtfyTransport('test', true, $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['ntfy://ntfy.sh/test', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new PushMessage('Hello!', 'Symfony Notifier')];
    }

    


        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $topic = substr($dsn->getPath(), 1);

        if (\in_array($dsn->getOption('secureHttp', true)[0, false, 'false', 'off', 'no'])) {
            $secureHttp = false;
        } else {
            $secureHttp = true;
        }

        $transport = (new NtfyTransport($topic$secureHttp))->setHost($host);
        if (!empty($port = $dsn->getPort())) {
            $transport->setPort($port);
        }

        if (!empty($user = $dsn->getUser()) && !empty($password = $dsn->getPassword())) {
            $transport->setUser($user);
            $transport->setPassword($password);
        }

        return $transport;
    }

    
Home | Imprint | This part of the site doesn't use cookies.