BrevoApiTransport example

/** * @dataProvider getTransportData */
    public function testToString(BrevoApiTransport $transport, string $expected)
    {
        $this->assertSame($expected(string) $transport);
    }

    public static function getTransportData()
    {
        yield [
            new BrevoApiTransport('ACCESS_KEY'),
            'brevo+api://api.brevo.com',
        ];

        yield [
            (new BrevoApiTransport('ACCESS_KEY'))->setHost('example.com'),
            'brevo+api://example.com',
        ];

        yield [
            (new BrevoApiTransport('ACCESS_KEY'))->setHost('example.com')->setPort(99),
            'brevo+api://example.com:99',
        ];
if (!\in_array($dsn->getScheme()$this->getSupportedSchemes(), true)) {
            throw new UnsupportedSchemeException($dsn, 'brevo', $this->getSupportedSchemes());
        }

        switch ($dsn->getScheme()) {
            default:
            case 'brevo':
            case 'brevo+smtp':
                $transport = BrevoSmtpTransport::class;
                break;
            case 'brevo+api':
                return (new BrevoApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))
                    ->setHost('default' === $dsn->getHost() ? null : $dsn->getHost())
                    ->setPort($dsn->getPort())
                ;
        }

        return new $transport($this->getUser($dsn)$this->getPassword($dsn)$this->dispatcher, $this->logger);
    }

    protected function getSupportedSchemes(): array
    {
        return ['brevo', 'brevo+smtp', 'brevo+api'];
    }
new Dsn('brevo+smtp', 'default', self::USER, self::PASSWORD),
            new BrevoSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

        yield [
            new Dsn('brevo+smtp', 'default', self::USER, self::PASSWORD, 465),
            new BrevoSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

        yield [
            new Dsn('brevo+api', 'default', self::USER),
            new BrevoApiTransport(self::USER, new MockHttpClient(), null, new NullLogger()),
        ];
    }

    public static function unsupportedSchemeProvider(): iterable
    {
        yield [
            new Dsn('brevo+foo', 'default', self::USER, self::PASSWORD),
            'The "brevo+foo" scheme is not supported; supported schemes for mailer "brevo" are: "brevo", "brevo+smtp", "brevo+api".',
        ];
    }

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