You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacter::reactTo method changes reaction rate directly using Eloquent update method:
$reaction->update([
'rate' => $rate,
]);
But method update does not exist on Cog\Contracts\Love\Reaction\Models\Reaction interface.
New Implementation
We can add changeRate method to the Reaction interface.
publicfunction changeRate(float$rate): void;
We could move check for same rate value out from the Reacter::reactTo method to new Reaction::changeRate method.
if ($reaction->getRate() === $rate) {
thrownewReactionAlreadyExists(
sprintf('Reaction of type `%s` with `%s` rate already exists.', $reactionType->getName(), $rate)
);
}
This will require to introduce new exception like RateInvalid.
The text was updated successfully, but these errors were encountered:
Motivation
Reacter::reactTo
method changes reaction rate directly using Eloquentupdate
method:But method
update
does not exist onCog\Contracts\Love\Reaction\Models\Reaction
interface.New Implementation
We can add
changeRate
method to theReaction
interface.We could move check for same rate value out from the
Reacter::reactTo
method to newReaction::changeRate
method.This will require to introduce new exception like
RateInvalid
.The text was updated successfully, but these errors were encountered: