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

Pass conditional value to callback #24

Open
Gummibeer opened this issue Mar 4, 2021 · 0 comments
Open

Pass conditional value to callback #24

Gummibeer opened this issue Mar 4, 2021 · 0 comments

Comments

@Gummibeer
Copy link
Member

The when() method accepts a value it will use as condition. It would be great to be able to access this value in the callback as argument as it's more common to do something like $mail->when($user->email, fn($mail, $email) => $mail->to($email)) then using empty() function or call the value retriever again in the callback.

Because we already pass the instance when() is called on as first argument and this change shouldn't be breaking we should pass the value as second argument to the callback. As PHP ignores additional arguments this change isn't breaking.

This should only be applied to the callback way and not the higher-order-proxy as we have no idea to which argument we should pass the value and this could also be breaking.

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

No branches or pull requests

1 participant