Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Dsn.php

function Dsn::fromString

1 call to Dsn::fromString()
Transport::parseDsn in vendor/symfony/mailer/Transport.php

File

vendor/symfony/mailer/Transport/Dsn.php, line 31

Class

Dsn
@author Konstantin Myakshin <molodchick@gmail.com>

Namespace

Symfony\Component\Mailer\Transport

Code

public static function fromString(string $dsn) : self {
    if (false === ($params = parse_url($dsn))) {
        throw new InvalidArgumentException('The mailer DSN is invalid.');
    }
    if (!isset($params['scheme'])) {
        throw new InvalidArgumentException('The mailer DSN must contain a scheme.');
    }
    if (!isset($params['host'])) {
        throw new InvalidArgumentException('The mailer DSN must contain a host (use "default" by default).');
    }
    $user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;
    $password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;
    $port = $params['port'] ?? null;
    parse_str($params['query'] ?? '', $query);
    return new self($params['scheme'], $params['host'], $user, $password, $port, $query);
}
RSS feed
Powered by Drupal