8000 Simplify code · symfony/symfony@9716a89 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9716a89

Browse files
committed
Simplify code
1 parent c5703ae commit 9716a89

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Symfony/Component/Mailer/Transport.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public function fromStrings(#[\SensitiveParameter] array $dsns): Transports
107107
public function fromString(#[\SensitiveParameter] string $dsn): TransportInterface
108108
{
109109
[$transport, $offset] = $this->parseDsn($dsn);
110-
$dnsWithoutMainOptions = preg_replace('/[?&]retry_period=\d+/', '', $dsn);
111-
if ($offset !== \strlen($dnsWithoutMainOptions)) {
110+
if ($offset !== \strlen($dsn)) {
112111
throw new InvalidArgumentException('The mailer DSN has some garbage at the end.');
113112
}
114113

@@ -122,10 +121,6 @@ private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0):
122121
'roundrobin' => RoundRobinTransport::class,
123122
];
124123

125-
$parsedUrl = parse_url($dsn);
126-
parse_str($parsedUrl['query'] ?? '', $query);
127-
$retryPeriod = min((int) ($query['retry_period'] ?? 60), 60);
128-
129124
while (true) {
130125
foreach ($keywords as $name => $class) {
131126
$name .= '(';
@@ -150,7 +145,12 @@ private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0):
150145
}
151146
}
152147

153-
return [new $class($args, $retryPeriod), $offset];
148+
parse_str(substr($dsn, $offset + 1), $query);
149+
if ($period = $query['retry_period'] ?? 0) {
150+
return [new $class($args, (int) $period), $offset + \strlen('retry_period='.$period) + 1];
151+
}
152+
153+
return [new $class($args), $offset];
154154
}
155155
}
156156

0 commit comments

Comments
 (0)
0