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

Introduce ReactionTypeable interface #2

Open
antonkomarev opened this issue Dec 21, 2019 · 0 comments
Open

Introduce ReactionTypeable interface #2

antonkomarev opened this issue Dec 21, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@antonkomarev
Copy link
Collaborator

antonkomarev commented Dec 21, 2019

Follow up to the Interface Segregation Principle violation fix PR #1

I propose to extract ReactionTypeable interface from Reaction & ReactionCounter models. It will be a breaking change.

interface ReactionTypeable
{
    public function getReactionType(): ReactionType;

    public function isOfReactionType(ReactionType $type): bool;

    public function isNotOfReactionType(ReactionType $type): bool;
}
$reactionType = $reaction->getReactionType();
$isTrue = $reaction->isOfReactionType($reactionType);
$isFalse = $reaction->isNotOfReactionType($reactionType);

$reactionType = $counter->getReactionType();
$isTrue = $counter->isOfReactionType($reactionType);
$isFalse = $counter->isNotOfReactionType($reactionType);

Current implementation

  1. Methods from the Reaction model doesn't have reaction word because initially I've thought that it's redundant:
public function getType(): ReactionType;

public function isOfType(ReactionType $type): bool;

public function isNotOfType(ReactionType $type): bool;
  1. Methods from the ReactionCounter model:
public function getReactionType(): ReactionType;

public function isReactionOfType(ReactionType $type): bool;

public function isNotReactionOfType(ReactionType $type): bool;
New generic method Current Reaction method Current ReactionCounter method
getReactionType getType getReactionType (same)
isOfReactionType isOfType isReactionOfType
isNotOfReactionType isNotOfType isNotReactionOfType
@antonkomarev antonkomarev added the enhancement New feature or request label Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant