-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message: add References
and In-Reply-To
headers shortcuts
#230
Conversation
src/Message/AbstractMessage.php
Outdated
* | ||
* @return array | ||
*/ | ||
final public function getReferences() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add array
return type
src/Message/AbstractMessage.php
Outdated
$references = $this->getHeaders()->get('references'); | ||
|
||
if (\is_array($references)) { | ||
return \array_unique($references); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like it very much to alter a header content. Emailing is a brittle system full of exceptions: even though it seems harmless, I would prefer to let the user do it if needed.
src/Message/AbstractMessage.php
Outdated
return \array_unique($references); | ||
} | ||
|
||
return []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a single return with ternary operator:
return \is_array($references) ? $references : [];
tests/MessageTest.php
Outdated
|
||
$message = $this->mailbox->getMessage(1); | ||
|
||
$this->assertSame(2, \count($message->getReferences())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertCount
tests/fixtures/references.eml
Outdated
Message-ID: <[email protected]> | ||
From: no_host | ||
Cc: "This one: is \"right\"" <[email protected]>, No-address | ||
References: <[email protected]> <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be so kind to also add the same API for In-Reply-To
header?
https://tools.ietf.org/html/rfc4021#section-2.1.9
https://tools.ietf.org/html/rfc2822#section-3.6.4
It seems to have exactly the same behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this 2b4f5af
tests/MessageTest.php
Outdated
|
||
$message = $this->mailbox->getMessage(2); | ||
|
||
$this->assertSame(0, \count($message->getReferences())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertCount
|
||
$message = $this->mailbox->getMessage(1); | ||
|
||
$this->assertCount(2, $message->getReferences()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add also specific assertion to the content of the referencies, e.g. $this->assertContains('<[email protected]>, $message->getReferences());'
* | ||
* @return array | ||
*/ | ||
final public function getInReplyTo(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add these two new signatureto Message\BasicMessageInterface
References
and In-Reply-To
headers shortcuts
Thank you @wujku |
No description provided.