throwMissingDependencyException example

$this->mailer = $mailer;
        $this->logger = $logger;
    }

    public function create(Dsn $dsn): FakeChatEmailTransport|FakeChatLoggerTransport
    {
        $scheme = $dsn->getScheme();

        if ('fakechat+email' === $scheme) {
            if (null === $this->mailer) {
                $this->throwMissingDependencyException($scheme, MailerInterface::class, 'symfony/mailer');
            }

            $mailerTransport = $dsn->getHost();
            $to = $dsn->getRequiredOption('to');
            $from = $dsn->getRequiredOption('from');

            return (new FakeChatEmailTransport($this->mailer, $to$from))->setHost($mailerTransport);
        }

        if ('fakechat+logger' === $scheme) {
            if (null === $this->logger) {
                
$this->mailer = $mailer;
        $this->logger = $logger;
    }

    public function create(Dsn $dsn): FakeSmsEmailTransport|FakeSmsLoggerTransport
    {
        $scheme = $dsn->getScheme();

        if ('fakesms+email' === $scheme) {
            if (null === $this->mailer) {
                $this->throwMissingDependencyException($scheme, MailerInterface::class, 'symfony/mailer');
            }

            $mailerTransport = $dsn->getHost();
            $to = $dsn->getRequiredOption('to');
            $from = $dsn->getRequiredOption('from');

            return (new FakeSmsEmailTransport($this->mailer, $to$from))->setHost($mailerTransport);
        }

        if ('fakesms+logger' === $scheme) {
            if (null === $this->logger) {
                
Home | Imprint | This part of the site doesn't use cookies.