Skip to content

Commit

Permalink
[Messenger] Allow passing a string instead of an array in `TransportN…
Browse files Browse the repository at this point in the history
…amesStamp`
  • Loading branch information
alexandre-daubois committed Feb 7, 2023
1 parent 3e79a27 commit 591f1f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CHANGELOG
`Symfony\Component\Messenger\Transport\InMemoryTransportFactory` in favor of
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport` and
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory`
* Allow passing a string instead of an array in `TransportNamesStamp`

6.2
---
Expand Down
9 changes: 6 additions & 3 deletions src/Symfony/Component/Messenger/Stamp/TransportNamesStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
*/
final class TransportNamesStamp implements StampInterface
{
private array $transportNames;

/**
* @param string[] $transports Transport names to be used for the message
* @param string[]|string $transports Transport names to be used for the message
*/
public function __construct(private array $transports)
public function __construct(array|string $transports)
{
$this->transportNames = (array) $transports;
}

public function getTransportNames(): array
{
return $this->transports;
return $this->transportNames;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ public function testGetSenders()
$this->assertSame($sender, $stampSenders[$key]);
}
}

public function testGetIndividualSender()
{
$stamp = new TransportNamesStamp('first_transport');
$stampSenders = $stamp->getTransportNames();

$this->assertCount(1, $stampSenders);
$this->assertSame('first_transport', $stampSenders[0]);
}
}

0 comments on commit 591f1f4

Please sign in to comment.