-
Notifications
You must be signed in to change notification settings - Fork 41
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
Unnecessary methods in ClientInterface? #24
Comments
@sagikazarmark very fair criticism of the interface, I wholeheartedly agree. On the options: I feel extending another interface makes most sense, I for now struggle with the name. |
Callable and Configurable interface are probably more generic. |
Further thinking about it: I think that the main interface should be the one containing call and multicall. So it should be ClientInterface. Of course, it is a BC breaking change. |
I would do something like this: interface CallClientInterface
{
public function call(string $method, array $arguments): mixed;
}
interface MulticallClientInterface
{
public function multicall(): MulticallInterface;
}
interface ClientInterface extends CallClientInterface, MulticallClientInterface
{
}
interface HandlerInterface
{
public function onError(callable $handler): HandlerInterface;
public function onSuccess(callable $handler): HandlerInterface;
}
interface MulticallInterface extends HandlerInterface
{
public addCall(string $methodName, array $params = [], callable $onSuccess = null, callable $onErrors = null): MulticallInterface;
public function execute(): array;
} What do you think? |
Not sure I understand the reason of having a separate handler interface. Other than that it looks good. |
Yeah, good point. Maybe calling it |
Yeah, builder sounds good. |
@sagikazarmark can you have a look? |
Looks good. |
Merged into develop |
I am working with your package for a long time now, so I have some experience with it. I created a few clients implementing
ClientInterface
and I hardly ever used methods other thancall
andmulticall
. The rest of methods seems to me an implementation detail, which might be useful in the default client, but makes implementing the interface harder. So I am suggesting a BC breaking and a non BC breaking solution to make things cleaner:What do you think? (It also follows the single responsibility principle by splitting into a callable and a configurable interface)
The text was updated successfully, but these errors were encountered: