Add helper method to determine reactionType type.
authorJoshua Rüsweg <josh@bastelstu.be>
Fri, 13 Apr 2018 19:18:24 +0000 (21:18 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Fri, 13 Apr 2018 19:18:24 +0000 (21:18 +0200)
See #2508

wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php

index e4f96ffaaf8377623c3fd5f3319179388c9ccbdd..d95cbc0737fa33532d6fe0dffef32c3a7d563e2a 100644 (file)
@@ -69,7 +69,7 @@ class ReactionType extends DatabaseObject {
        /**
         * Renders the reaction icon.
         * 
-        * @return      string
+        * @return      string
         */
        public function renderIcon(): string {
                switch ($this->iconType) {
@@ -100,4 +100,31 @@ class ReactionType extends DatabaseObject {
                                break;
                }
        }
+       
+       /**
+        * Returns true, if reaction is a positive reaction.
+        * 
+        * @return      bool
+        */
+       public function isPositive() {
+               return $this->type == self::REACTION_TYPE_POSITIVE;
+       }
+       
+       /**
+        * Returns true, if reaction is a negative reaction.
+        *
+        * @return      bool
+        */
+       public function isNegative() {
+               return $this->type == self::REACTION_TYPE_NEGATIVE;
+       }
+       
+       /**
+        * Returns true, if reaction is a neutral reaction.
+        *
+        * @return      bool
+        */
+       public function isNeutral() {
+               return $this->type == self::REACTION_TYPE_NEUTRAL;
+       }
 }