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

Add When operation. #105

Merged
merged 4 commits into from
Jun 13, 2021
Merged

Add When operation. #105

merged 4 commits into from
Jun 13, 2021

Conversation

drupol
Copy link
Collaborator

@drupol drupol commented Jun 12, 2021

This PR

  • Add When operation
  • Has documentation
  • Has tests

@AlexandruGG
Copy link
Collaborator

At first glance I can't tell what's the difference between this and IfThenElse? 🤔

@drupol
Copy link
Collaborator Author

drupol commented Jun 13, 2021

At first glance I can't tell what's the difference between this and IfThenElse? thinking

This operation operates on the collection object once, while the ifThenElse operates on each item of the collection (this is an alias for a map).

@drupol drupol merged commit 25d4029 into master Jun 13, 2021
@drupol drupol deleted the feature/add-when-operation branch June 13, 2021 06:20
Comment on lines +26 to +28
* @return \loophp\collection\Collection<TKey, T>
*/
public function when(callable $predicate, callable $whenTrue, ?callable $whenFalse = null): Collection;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this return Collection the implementation or Collection the contract?

Isn't there a mismatch here? the @return is showing the implementation, but the actual return type of the function is the contract

@AlexandruGG
Copy link
Collaborator

At first glance I can't tell what's the difference between this and IfThenElse? thinking

This operation operates on the collection object once, while the ifThenElse operates on each item of the collection (this is an alias for a map).

I understand now, thanks for clarifying this in the docs! 🙌

@AlexandruGG
Copy link
Collaborator

@drupol do you mind adding the static analysis check with any new operation please? This ensures we get the types right on the user side 😁

@drupol
Copy link
Collaborator Author

drupol commented Jun 13, 2021

True ! I have to get used to that, will do that later in the day for sure.

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

Successfully merging this pull request may close these issues.

None yet

2 participants