function Transport::parseDsn
1 call to Transport::parseDsn()
- Transport::fromString in vendor/
symfony/ mailer/ Transport.php
File
-
vendor/
symfony/ mailer/ Transport.php, line 117
Class
- Transport
- @author Fabien Potencier <fabien@symfony.com> @author Konstantin Myakshin <molodchick@gmail.com>
Namespace
Symfony\Component\MailerCode
private function parseDsn(string $dsn, int $offset = 0) : array {
static $keywords = [
'failover' => FailoverTransport::class,
'roundrobin' => RoundRobinTransport::class,
];
while (true) {
foreach ($keywords as $name => $class) {
$name .= '(';
if ($name === substr($dsn, $offset, \strlen($name))) {
$offset += \strlen($name) - 1;
preg_match('{\\(([^()]|(?R))*\\)}A', $dsn, $matches, 0, $offset);
if (!isset($matches[0])) {
continue;
}
++$offset;
$args = [];
while (true) {
[
$arg,
$offset,
] = $this->parseDsn($dsn, $offset);
$args[] = $arg;
if (\strlen($dsn) === $offset) {
break;
}
++$offset;
if (')' === $dsn[$offset - 1]) {
break;
}
}
return [
new $class($args),
$offset,
];
}
}
if (preg_match('{(\\w+)\\(}A', $dsn, $matches, 0, $offset)) {
throw new InvalidArgumentException(\sprintf('The "%s" keyword is not valid (valid ones are "%s"), ', $matches[1], implode('", "', array_keys($keywords))));
}
if ($pos = strcspn($dsn, ' )', $offset)) {
return [
$this->fromDsnObject(Dsn::fromString(substr($dsn, $offset, $pos))),
$offset + $pos,
];
}
return [
$this->fromDsnObject(Dsn::fromString(substr($dsn, $offset))),
\strlen($dsn),
];
}
}