-
Notifications
You must be signed in to change notification settings - Fork 308
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
Constructor signature - new Pusher(...) #66
Comments
I would go with the first option. As long as any boolean type parameters are kept in the 4th argument array. I always feel passing boolean parameters in that way is much better for readability. I do think the |
@tanuck To clarify: would you'd prefer: use Pusher\Pusher;
use Pusher\Config;
$pusher = new Pusher(new Config('my-app-id', 'my-app-key', 'my-app-secret', array('encrypted' => true))); For me:
But happy to add this as a +1 for the |
No. That option is a bit too cluttered for me. And I agree about the 2 use statements. I was happy with your first example from option 1: $pusher = new Pusher('my-app-id', 'my-app-key', 'my-app-secret', array('encrypted' => true)); But keep the Config class for internal use. Instead of cluttered the Pusher class with additional config related properties. It would be good to decide on this and merge the implementation before looking at #68 |
👍 Yep - good call on keeping the internal class. Agree RE #68 too. |
Okay 👍 |
Updates to the library constructor - #66
Fixed in #69. |
We want to keep the constructor as simple as possible. I'd suggest the use of the current
Config
object adds additional and unnecessary complexity.A key part of doing this will be providing default values for things that were otherwise extracted from the URL:
My vote is for one of the following:
1. Directly passing required parameters as arguments
Additional options are added by a 4th
options
parameter:2. Using an Associative Array with named parameters
Optional parameters are just added to the array:
The benefit of this approach is that it reduces the changes of getting key and secret mixed up.
What do others think? @zimbatm
The text was updated successfully, but these errors were encountered: