Skip to content

Commit

Permalink
Optimized MailManager::createSmtpTransport (#694)
Browse files Browse the repository at this point in the history
* Update MailManager.php

* Revert "Update MailManager.php"

This reverts commit 1a9f6c9.

* feat: Refactor MailManager.php to improve readability and maintainability

The code changes in `MailManager.php` refactor the `createSmtpTransport` method to improve readability and maintainability. The changes include type casting for certain configuration values and use of the null coalescing operator to handle missing values. This ensures that the method creates the SMTP transport correctly.

Note: This message has been generated based on the provided code changes and recent commits.

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
zds-s and huangdijia authored Jul 26, 2024
1 parent 00cbef3 commit 868c8e5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mail/src/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ protected function resolve(string $name): Mailer
protected function createSmtpTransport(array $config): EsmtpTransport
{
$factory = new EsmtpTransportFactory();

$scheme = $config['scheme'] ?? null;

if (! $scheme) {
Expand All @@ -215,10 +214,10 @@ protected function createSmtpTransport(array $config): EsmtpTransport
/** @var EsmtpTransport $transport */
$transport = $factory->create(new Dsn(
$scheme,
$config['host'],
$config['username'] ?? null,
$config['password'] ?? null,
$config['port'] ?? null,
(string) $config['host'],
isset($config['username']) ? ((string) $config['username']) : null,
isset($config['password']) ? ((string) $config['password']) : null,
isset($config['port']) ? ((int) $config['port']) : null,
$config
));

Expand Down

0 comments on commit 868c8e5

Please sign in to comment.