Skip to content

Commit

Permalink
add class for Return-Path header
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed Jan 28, 2025
1 parent e27527b commit b848d0f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Header/ReturnPath.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);

namespace Genkgo\Mail\Header;

use Genkgo\Mail\EmailAddress;
use Genkgo\Mail\HeaderInterface;

final class ReturnPath implements HeaderInterface
{
/**
* @var EmailAddress
*/
private $reversePath;

/**
* @param EmailAddress $reversePath
*/
public function __construct(EmailAddress $reversePath)
{
$this->reversePath = $reversePath;
}

/**
* @return HeaderName
*/
public function getName(): HeaderName
{
return new HeaderName('Return-Path');
}

/**
* @return HeaderValue
*/
public function getValue(): HeaderValue
{
return HeaderValue::fromEncodedString((string)$this->reversePath);
}
}
32 changes: 32 additions & 0 deletions test/Unit/Header/ReturnPathTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

namespace Genkgo\TestMail\Unit\Header;

use Genkgo\Mail\Header\ReturnPath;
use Genkgo\TestMail\AbstractTestCase;
use Genkgo\Mail\EmailAddress;

final class ReturnPathTest extends AbstractTestCase
{
/**
* @test
* @dataProvider provideValues
*/
public function it_produces_correct_values($recipientEmail, $headerName, $headerValue): void
{
$header = new ReturnPath(new EmailAddress($recipientEmail));
$this->assertEquals($headerName, (string)$header->getName());
$this->assertEquals($headerValue, (string)$header->getValue());
}

/**
* @return array
*/
public function provideValues(): array
{
return [
['[email protected]', 'Return-Path', '[email protected]'],
];
}
}

0 comments on commit b848d0f

Please sign in to comment.