minor #33787 [Mailer] Tweak some code (fabpot)

This PR was merged into the 4.4 branch.

Discussion
----------

[Mailer] Tweak some code

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

Tweaks from the Notifier PR.

Commits
-------

ab094c02eb [Mailer] Tweak some code
This commit is contained in:
Fabien Potencier 2019-10-01 13:38:59 +02:00
commit 11da6f6eea
2 changed files with 4 additions and 6 deletions

View File

@ -35,7 +35,7 @@ class RoundRobinTransport implements TransportInterface
public function __construct(array $transports, int $retryPeriod = 60)
{
if (!$transports) {
throw new TransportException(__CLASS__.' must have at least one transport configured.');
throw new TransportException(sprintf('"%s" must have at least one transport configured.', static::class));
}
$this->transports = $transports;
@ -58,9 +58,7 @@ class RoundRobinTransport implements TransportInterface
public function __toString(): string
{
return $this->getNameSymbol().'('.implode(' ', array_map(function (TransportInterface $transport) {
return (string) $transport;
}, $this->transports)).')';
return $this->getNameSymbol().'('.implode(' ', array_map('strval', $this->transports)).')';
}
/**

View File

@ -21,7 +21,7 @@ use Symfony\Component\Mime\RawMessage;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class Transports implements TransportInterface
final class Transports implements TransportInterface
{
private $transports;
private $default;
@ -64,6 +64,6 @@ class Transports implements TransportInterface
public function __toString(): string
{
return 'all';
return '['.implode(',', array_keys($this->transports)).']';
}
}