File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
contracts/Reaction/Exceptions Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 1414namespace Cog \Contracts \Love \Reaction \Exceptions ;
1515
1616use Cog \Contracts \Love \Exceptions \LoveThrowable ;
17+ use Cog \Contracts \Love \ReactionType \Models \ReactionType ;
1718use RuntimeException ;
1819
1920final class ReactionAlreadyExists extends RuntimeException implements
2021 LoveThrowable
2122{
23+ public static function ofType (ReactionType $ reactionType ): self
24+ {
25+ return new self (sprintf (
26+ 'Reaction of type `%s` already exists. ' ,
27+ $ reactionType ->getName ()
28+ ));
29+ }
2230}
Original file line number Diff line number Diff line change @@ -95,10 +95,7 @@ public function reactTo(
9595 }
9696
9797 if ($ rate === null ) {
98- throw new ReactionAlreadyExists (sprintf (
99- 'Reaction of type `%s` already exists. ' ,
100- $ reactionType ->getName ()
101- ));
98+ throw ReactionAlreadyExists::ofType ($ reactionType );
10299 }
103100
104101 $ reaction ->changeRate ($ rate );
You can’t perform that action at this time.
0 commit comments