Skip to content
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

Merged
merged 8 commits into from
Oct 9, 2017

Conversation

wujku
Copy link
Contributor

@wujku wujku commented Oct 6, 2017

No description provided.

*
* @return array
*/
final public function getReferences()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add array return type

$references = $this->getHeaders()->get('references');

if (\is_array($references)) {
return \array_unique($references);
Copy link
Collaborator

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.

return \array_unique($references);
}

return [];
Copy link
Collaborator

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 : [];


$message = $this->mailbox->getMessage(1);

$this->assertSame(2, \count($message->getReferences()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertCount

Message-ID: <[email protected]>
From: no_host
Cc: "This one: is \"right\"" <[email protected]>, No-address
References: <[email protected]> <[email protected]>
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this 2b4f5af


$message = $this->mailbox->getMessage(2);

$this->assertSame(0, \count($message->getReferences()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertCount

@Slamdunk Slamdunk added this to the 1.1 milestone Oct 6, 2017

$message = $this->mailbox->getMessage(1);

$this->assertCount(2, $message->getReferences());
Copy link
Collaborator

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
Copy link
Collaborator

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

@Slamdunk Slamdunk changed the title Added getReferences method Message: add References and In-Reply-To headers shortcuts Oct 9, 2017
@Slamdunk Slamdunk merged commit 400c52e into ddeboer:master Oct 9, 2017
@Slamdunk
Copy link
Collaborator

Slamdunk commented Oct 9, 2017

Thank you @wujku

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants