PostmarkApiTransport example


    public function testToString(PostmarkApiTransport $transport, string $expected)
    {
        $this->assertSame($expected(string) $transport);
    }

    public static function getTransportData()
    {
        return [
            [
                new PostmarkApiTransport('KEY'),
                'postmark+api://api.postmarkapp.com',
            ],
            [
                (new PostmarkApiTransport('KEY'))->setHost('example.com'),
                'postmark+api://example.com',
            ],
            [
                (new PostmarkApiTransport('KEY'))->setHost('example.com')->setPort(99),
                'postmark+api://example.com:99',
            ],
        ];
    }
new Dsn('postmark+smtp', 'example.com'),
            true,
        ];
    }

    public static function createProvider(): iterable
    {
        $logger = new NullLogger();

        yield [
            new Dsn('postmark+api', 'default', self::USER),
            new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger),
        ];

        yield [
            new Dsn('postmark+api', 'example.com', self::USER, '', 8080),
            (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080),
        ];

        yield [
            new Dsn('postmark+api', 'example.com', self::USER, '', 8080, ['message_stream' => 'broadcasts']),
            (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080)->setMessageStream('broadcasts'),
        ];

        

    public function create(Dsn $dsn): TransportInterface
    {
        $transport = null;
        $scheme = $dsn->getScheme();
        $user = $this->getUser($dsn);

        if ('postmark+api' === $scheme) {
            $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
            $port = $dsn->getPort();

            $transport = (new PostmarkApiTransport($user$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('postmark+smtp' === $scheme || 'postmark+smtps' === $scheme || 'postmark' === $scheme) {
            $transport = new PostmarkSmtpTransport($user$this->dispatcher, $this->logger);
        }

        if (null !== $transport) {
            $messageStream = $dsn->getOption('message_stream');

            if (null !== $messageStream) {
                $transport->setMessageStream($messageStream);
            }
Home | Imprint | This part of the site doesn't use cookies.