Skip to content

Commit

Permalink
Add IMessage::getSubject
Browse files Browse the repository at this point in the history
  • Loading branch information
zbateson committed Apr 23, 2024
1 parent 663ed66 commit 20cd88e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/IMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
*/
interface IMessage extends IMimePart
{
/**
* Returns the subject of the message, retrieved from the 'Subject' header,
* or null if the message has none set.
*/
public function getSubject() : ?string;

/**
* Returns the inline text/plain IMessagePart for a message.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public function isMime() : bool
return ($contentType !== null || $mimeVersion !== null);
}

public function getSubject() : ?string
{
return $this->getHeaderValue(HeaderConsts::SUBJECT);
}

public function getTextPart(int $index = 0) : ?IMessagePart
{
return $this->getPart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function runEmailTestForMessage($message, array $props, $failMessage) :
}

if (isset($props['Subject'])) {
$this->assertEquals($props['Subject'], $message->getHeaderValue('subject'), $failMessage);
$this->assertEquals($props['Subject'], $message->getSubject(), $failMessage);
}

if (isset($props['Date'])) {
Expand Down

0 comments on commit 20cd88e

Please sign in to comment.