Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Conversation

@mcordingley
Copy link
Contributor

I find myself in situations where other messages may have been sent after the one that I'm interested in making an assertion about. I can continue to have these locally, but they should be of more general use to others.

In particular, this should help with #53. The assertion methods may easily be rewritten to take advantage of these methods to become more general in which email gets matched.

@psaunders
Copy link

psaunders commented Oct 29, 2016

Can this be merged in please? It's something I've ended up doing myself too

@mcordingley
Copy link
Contributor Author

Looking like this pull isn't wanted. I'll delete my fork and close the pull if it continues to be inactive to stop cluttering up this repo and my own account.

@mattstauffer
Copy link
Member

Guys, we're really busy. This is an insane season, and my wife just had a baby, and some times open source has to be the first thing to get pushed down the road.

Your pull is not unwanted. If it is, we would say it's unwanted. Sorry, but some times things just take time. Thanks for your PR, and I hope someone will be able to find time to look at it soon.

@mcordingley
Copy link
Contributor Author

@mattstauffer

Appreciate that. I'm just getting unfortunately used to having pulls to various projects get ignored for months on end. Worst offender was six months without even a response.

public function getMessagesFor(array $emails)
{
return $this->getMessages()->filter(function (Message $message) use ($emails) {
foreach ($emails as $email) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability's sake, maybe consider:

return collect($emails)->contains(function ($email) use ($message) {
   return $message->hasRecipient($email);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it.

@besologic
Copy link
Contributor

besologic commented Nov 18, 2016

@mcordingley Thanks again for your patience, and to reiterate @mattstauffer's comments, we really appreciate your contribution!

Overall this is close! I made a readability suggestion and I'd like to see tests for the new methods.

* @param array $emails
* @return MailThiefCollection
*/
public function getMessagesFor(array $emails)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this intended to be used with singular and multiple emails being passed in; consider removing the typehint and add the following:

if (! is_array($emails)) {
   $emails = [$emails];
}

This allows you to rewrite line 55 with return $this->getMessagesFor($email)->last();.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, I think you could also do:

$emails = (array) $emails;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I generally like using as strict of type hints as possible, which means not having arguments that could be different types. But, I see how this would be much nicer from a user perspective to take in both strings and arrays. Updating the code to match now.

@mcordingley
Copy link
Contributor Author

I have some time coming up soon. I'll see what I can do.

@mcordingley
Copy link
Contributor Author

Tests added. These changes should be good to go, now.

@besologic besologic merged commit 9e073e4 into tighten:master Nov 30, 2016
@besologic
Copy link
Contributor

👌🏼

Thank you! This is a great addition.

@mcordingley
Copy link
Contributor Author

Whoo! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants