Skip to content

Commit

Permalink
return-path should be using angle brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed Jan 29, 2025
1 parent d0fc5fb commit afecad6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Header/ReturnPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
final class ReturnPath implements HeaderInterface
{
/**
* @var EmailAddress
* @var ?EmailAddress
*/
private $reversePath;

/**
* @param EmailAddress $reversePath
* @param ?EmailAddress $reversePath
*/
public function __construct(EmailAddress $reversePath)
public function __construct(?EmailAddress $reversePath = null)
{
$this->reversePath = $reversePath;
}
Expand All @@ -34,6 +34,10 @@ public function getName(): HeaderName
*/
public function getValue(): HeaderValue
{
return HeaderValue::fromEncodedString((string)$this->reversePath);
if ($this->reversePath === null) {
return new HeaderValue('<>');
}

return HeaderValue::fromEncodedString('<' . $this->reversePath . '>');
}
}
5 changes: 3 additions & 2 deletions test/Unit/Header/ReturnPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ReturnPathTest extends AbstractTestCase
*/
public function it_produces_correct_values($recipientEmail, $headerName, $headerValue): void
{
$header = new ReturnPath(new EmailAddress($recipientEmail));
$header = new ReturnPath($recipientEmail);
$this->assertEquals($headerName, (string)$header->getName());
$this->assertEquals($headerValue, (string)$header->getValue());
}
Expand All @@ -26,7 +26,8 @@ public function it_produces_correct_values($recipientEmail, $headerName, $header
public function provideValues(): array
{
return [
['[email protected]', 'Return-Path', '[email protected]'],
[new EmailAddress('[email protected]'), 'Return-Path', '<[email protected]>'],
[null, 'Return-Path', '<>'],
];
}
}

0 comments on commit afecad6

Please sign in to comment.