Skip to content

Pass conditional value to callback #24

Open
@Gummibeer

Description

@Gummibeer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions