MailPaceApiTransport example

new Dsn('mailpace+smtp', 'example.com'),
            true,
        ];
    }

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

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

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

        yield [
            new Dsn('mailpace', 'default', self::USER),
            new MailPaceSmtpTransport(self::USER, null, $logger),
        ];

        

final class MailPaceTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): TransportInterface
    {
        $scheme = $dsn->getScheme();

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

            return (new MailPaceApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mailpace+smtp' === $scheme || 'mailpace+smtps' === $scheme || 'mailpace' === $scheme) {
            return new MailPaceSmtpTransport($this->getUser($dsn)$this->dispatcher, $this->logger);
        }

        throw new UnsupportedSchemeException($dsn, 'mailpace', $this->getSupportedSchemes());
    }

    protected function getSupportedSchemes(): array
    {
        

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

    public static function getTransportData(): array
    {
        return [
            [
                new MailPaceApiTransport('KEY'),
                'mailpace+api://app.mailpace.com/api/v1',
            ],
            [
                (new MailPaceApiTransport('KEY'))->setHost('example.com'),
                'mailpace+api://example.com',
            ],
            [
                (new MailPaceApiTransport('KEY'))->setHost('example.com')->setPort(99),
                'mailpace+api://example.com:99',
            ],
        ];
    }
Home | Imprint | This part of the site doesn't use cookies.