Repository: symfony/symfony
File: src/Symfony/Component/Mailer/Bridge/Mailtrap/Transport/MailtrapTransportFactory.php (PHP)

Code before:

use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
use Symfony\Component\Mailer\Transport\TransportInterface;

/**
 * @author Kevin Bond <kevinbond@gmail.com>
 */
final class MailtrapTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): TransportInterface
    {
        $scheme = $dsn->getScheme();
        $user = $this->getUser($dsn);

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

            if ('mailtrap+api' === $scheme) {
                return (new MailtrapApiTransport($user, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
            } else {
                $inboxId = $dsn->getOption('inboxId');

                return (new MailtrapApiSandboxTransport($user, $this->client, $this->dispatcher, $this->logger, $inboxId))->setHost($host)->setPort($port);
            }
        }

        if ('mailtrap+smtp' === $scheme || 'mailtrap+smtps' === $scheme || 'mailtrap' === $scheme) {
            return new MailtrapSmtpTransport($user, $this->dispatcher, $this->logger);
        }

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

    protected function getSupportedSchemes(): array
    {
        return ['mailtrap', 'mailtrap+api', 'mailtrap+sandbox', 'mailtrap+smtp', 'mailtrap+smtps'];
    }
}


Review comment (suggestion):
```suggestion
                return (new MailtrapApiSandboxTransport($user, $dsn->getOption('inboxId'), $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
```

Code after:

use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
use Symfony\Component\Mailer\Transport\TransportInterface;

/**
 * @author Kevin Bond <kevinbond@gmail.com>
 */
final class MailtrapTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): TransportInterface
    {
        $scheme = $dsn->getScheme();
        $user = $this->getUser($dsn);

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

            if ('mailtrap+api' === $scheme) {
                return (new MailtrapApiTransport($user, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
            } else {
                return (new MailtrapApiSandboxTransport($user, $dsn->getOption('inboxId'), $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
            }
        }

        if ('mailtrap+smtp' === $scheme || 'mailtrap+smtps' === $scheme || 'mailtrap' === $scheme) {
            return new MailtrapSmtpTransport($user, $this->dispatcher, $this->logger);
        }

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

    protected function getSupportedSchemes(): array
    {
        return ['mailtrap', 'mailtrap+api', 'mailtrap+sandbox', 'mailtrap+smtp', 'mailtrap+smtps'];
    }
}