MDL-50561 messages: Add missing __isset magic method
authorJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 11 Jun 2015 15:07:56 +0000 (17:07 +0200)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 19 Jun 2015 07:44:50 +0000 (09:44 +0200)
lib/classes/message/message.php

index 393d0e7..f75cce9 100644 (file)
@@ -215,6 +215,20 @@ class message {
         throw new \coding_exception("Invalid property $prop specified");
     }
 
+    /**
+     * Magic method to check if property is set.
+     *
+     * @param string $prop name of property to check.
+     * @return bool
+     * @throws \coding_exception
+     */
+    public function __isset($prop) {
+        if (in_array($prop, $this->properties)) {
+            return isset($this->$prop);
+        }
+        throw new \coding_exception("Invalid property $prop specified");
+    }
+
     /**
      * This method lets you define content that would be added to the message only for specific message processors.
      *