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

Remove supports/do pattern #1427

Open
ciaranmcnulty opened this issue Mar 20, 2022 · 0 comments
Open

Remove supports/do pattern #1427

ciaranmcnulty opened this issue Mar 20, 2022 · 0 comments

Comments

@ciaranmcnulty
Copy link
Member

We have this in a lot of places (Generators, Matchers, Presenters) where we have an interface like:

interface Foo
{
    public function supports(mixed ...$values): bool;
    public function do(mixed ...$values): Result;
}

The problem is the concrete classes have to support(mixed) and callers have to 'remember' to call supports() first.

Better might be a single method:

interface Foo
{
    public function doIfPossible(mixed ...$values): false|Result
}
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

No branches or pull requests

1 participant