Skip to content

Commit ceda107

Browse files
committed
Merge branch '4.4'
* 4.4: [Mailer] Renamed getName() to toString() Fix the profiler panel for Mailer
2 parents e7c70f3 + 529b0ea commit ceda107

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+109
-99
lines changed

AbstractTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function send(RawMessage $message, SmtpEnvelope $envelope = null): ?SentM
6767
}
6868
}
6969

70-
$event = new MessageEvent($message, $envelope, $this->getName());
70+
$event = new MessageEvent($message, $envelope, (string) $this);
7171
$this->dispatcher->dispatch($event);
7272
$envelope = $event->getEnvelope();
7373
if (!$envelope->getRecipients()) {

Amazon/Transport/SesApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(string $accessKey, string $secretKey, string $region
4343
parent::__construct($client, $dispatcher, $logger);
4444
}
4545

46-
public function getName(): string
46+
public function __toString(): string
4747
{
4848
return sprintf('api://%s@ses?region=%s', $this->accessKey, $this->region);
4949
}

Amazon/Transport/SesHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(string $accessKey, string $secretKey, string $region
4242
parent::__construct($client, $dispatcher, $logger);
4343
}
4444

45-
public function getName(): string
45+
public function __toString(): string
4646
{
4747
return sprintf('http://%s@ses?region=%s', $this->accessKey, $this->region);
4848
}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CHANGELOG
1111
* Added PHPUnit constraints
1212
* Added `MessageDataCollector`
1313
* Added `MessageEvents` and `MessageLoggerListener` to allow collecting sent emails
14-
* [BC BREAK] `TransportInterface` has a new `getName()` method
14+
* [BC BREAK] `TransportInterface` has a new `__toString()` method
1515
* [BC BREAK] Classes `AbstractApiTransport` and `AbstractHttpTransport` moved under `Transport` sub-namespace.
1616
* [BC BREAK] Transports depend on `Symfony\Contracts\EventDispatcher\EventDispatcherInterface`
1717
instead of `Symfony\Component\EventDispatcher\EventDispatcherInterface`.

EsmtpTransportTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@
1616

1717
class EsmtpTransportTest extends TestCase
1818
{
19-
public function testName()
19+
public function testToString()
2020
{
2121
$t = new EsmtpTransport();
22-
$this->assertEquals('smtp://localhost', $t->getName());
22+
$this->assertEquals('smtp://localhost', (string) $t);
2323

2424
$t = new EsmtpTransport('example.com');
2525
if (\defined('OPENSSL_VERSION_NUMBER')) {
26-
$this->assertEquals('smtps://example.com', $t->getName());
26+
$this->assertEquals('smtps://example.com', (string) $t);
2727
} else {
28-
$this->assertEquals('smtp://example.com', $t->getName());
28+
$this->assertEquals('smtp://example.com', (string) $t);
2929
}
3030

3131
$t = new EsmtpTransport('example.com', 2525);
32-
$this->assertEquals('smtp://example.com:2525', $t->getName());
32+
$this->assertEquals('smtp://example.com:2525', (string) $t);
3333

3434
$t = new EsmtpTransport('example.com', 0, true);
35-
$this->assertEquals('smtps://example.com', $t->getName());
35+
$this->assertEquals('smtps://example.com', (string) $t);
3636

3737
$t = new EsmtpTransport('example.com', 0, false);
38-
$this->assertEquals('smtp://example.com', $t->getName());
38+
$this->assertEquals('smtp://example.com', (string) $t);
3939

4040
$t = new EsmtpTransport('example.com', 466, true);
41-
$this->assertEquals('smtps://example.com:466', $t->getName());
41+
$this->assertEquals('smtps://example.com:466', (string) $t);
4242
}
4343
}

Event/MessageEvent.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ final class MessageEvent extends Event
2424
{
2525
private $message;
2626
private $envelope;
27-
private $transportName;
27+
private $transport;
2828
private $queued;
2929

30-
public function __construct(RawMessage $message, SmtpEnvelope $envelope, string $transportName, bool $queued = false)
30+
public function __construct(RawMessage $message, SmtpEnvelope $envelope, string $transport, bool $queued = false)
3131
{
3232
$this->message = $message;
3333
$this->envelope = $envelope;
34-
$this->transportName = $transportName;
34+
$this->transport = $transport;
3535
$this->queued = $queued;
3636
}
3737

@@ -55,9 +55,9 @@ public function setEnvelope(SmtpEnvelope $envelope): void
5555
$this->envelope = $envelope;
5656
}
5757

58-
public function getTransportName(): string
58+
public function getTransport(): string
5959
{
60-
return $this->transportName;
60+
return $this->transport;
6161
}
6262

6363
public function isQueued(): bool

Event/MessageEvents.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MessageEvents
2424
public function add(MessageEvent $event): void
2525
{
2626
$this->events[] = $event;
27-
$this->transports[$event->getTransportName()] = true;
27+
$this->transports[$event->getTransport()] = true;
2828
}
2929

3030
public function getTransports(): array
@@ -43,7 +43,7 @@ public function getEvents(string $name = null): array
4343

4444
$events = [];
4545
foreach ($this->events as $event) {
46-
if ($name === $event->getTransportName()) {
46+
if ($name === $event->getTransport()) {
4747
$events[] = $event;
4848
}
4949
}

FailoverTransportTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ public function testSendNoTransports()
2929
new FailoverTransport([]);
3030
}
3131

32-
public function testGetName()
32+
public function testToString()
3333
{
3434
$t1 = $this->createMock(TransportInterface::class);
35-
$t1->expects($this->once())->method('getName')->willReturn('t1://local');
35+
$t1->expects($this->once())->method('__toString')->willReturn('t1://local');
3636
$t2 = $this->createMock(TransportInterface::class);
37-
$t2->expects($this->once())->method('getName')->willReturn('t2://local');
37+
$t2->expects($this->once())->method('__toString')->willReturn('t2://local');
3838
$t = new FailoverTransport([$t1, $t2]);
39-
$this->assertEquals('t1://local || t2://local', $t->getName());
39+
$this->assertEquals('t1://local || t2://local', (string) $t);
4040
}
4141

4242
public function testSendFirstWork()

Mailchimp/Transport/MandrillApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3636
parent::__construct($client, $dispatcher, $logger);
3737
}
3838

39-
public function getName(): string
39+
public function __toString(): string
4040
{
4141
return sprintf('api://mandrill');
4242
}

Mailchimp/Transport/MandrillHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3434
parent::__construct($client, $dispatcher, $logger);
3535
}
3636

37-
public function getName(): string
37+
public function __toString(): string
3838
{
3939
return sprintf('http://mandrill');
4040
}

0 commit comments

Comments
 (0)