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 method chaining support to NullDriver #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imacrayon
Copy link

@imacrayon imacrayon commented Oct 16, 2024

I'm tagging subscribers in a few places with code like this:

$hash = Newsletter::getApi()->subscriberHash($user->email);
Newsletter::getApi()->post("lists/123/members/{$hash}/tags", [
    'tags' => [['name' => 'My Tag', 'status' => 'active']],
]);

In a local or testing environment I have NEWSLETTER_DRIVER=null set in my .env. However this causes getApi()->subscriberHash() to throw an exception since getApi() returns null when a Newsletter driver is not set.

This PR ensures NullDriver return itself when a method is called so that method calls can be chained. getApi()->subscriberHash() will now return an instance of NullDriver instead of throwing.

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.

1 participant