Skip to content

Introduce ReactionTypeable interface #2

Open
@antonkomarev

Description

@antonkomarev

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @antonkomarev

        Issue actions

          Introduce ReactionTypeable interface · Issue #2 · php-i/love