Skip to content

Commit afecad6

Browse files
committed
return-path should be using angle brackets
1 parent d0fc5fb commit afecad6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Header/ReturnPath.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
final class ReturnPath implements HeaderInterface
1010
{
1111
/**
12-
* @var EmailAddress
12+
* @var ?EmailAddress
1313
*/
1414
private $reversePath;
1515

1616
/**
17-
* @param EmailAddress $reversePath
17+
* @param ?EmailAddress $reversePath
1818
*/
19-
public function __construct(EmailAddress $reversePath)
19+
public function __construct(?EmailAddress $reversePath = null)
2020
{
2121
$this->reversePath = $reversePath;
2222
}
@@ -34,6 +34,10 @@ public function getName(): HeaderName
3434
*/
3535
public function getValue(): HeaderValue
3636
{
37-
return HeaderValue::fromEncodedString((string)$this->reversePath);
37+
if ($this->reversePath === null) {
38+
return new HeaderValue('<>');
39+
}
40+
41+
return HeaderValue::fromEncodedString('<' . $this->reversePath . '>');
3842
}
3943
}

test/Unit/Header/ReturnPathTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class ReturnPathTest extends AbstractTestCase
1515
*/
1616
public function it_produces_correct_values($recipientEmail, $headerName, $headerValue): void
1717
{
18-
$header = new ReturnPath(new EmailAddress($recipientEmail));
18+
$header = new ReturnPath($recipientEmail);
1919
$this->assertEquals($headerName, (string)$header->getName());
2020
$this->assertEquals($headerValue, (string)$header->getValue());
2121
}
@@ -26,7 +26,8 @@ public function it_produces_correct_values($recipientEmail, $headerName, $header
2626
public function provideValues(): array
2727
{
2828
return [
29-
['[email protected]', 'Return-Path', '[email protected]'],
29+
[new EmailAddress('[email protected]'), 'Return-Path', '<[email protected]>'],
30+
[null, 'Return-Path', '<>'],
3031
];
3132
}
3233
}

0 commit comments

Comments
 (0)