Bsitu has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52191


Change subject: Add more documentation and getter method to Notification
......................................................................

Add more documentation and getter method to Notification

Change-Id: Idb64de7034e7ff3c615dcee6fe814d64102f66cc
---
M model/Notification.php
1 file changed, 46 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/91/52191/1

diff --git a/model/Notification.php b/model/Notification.php
index e8b4900..5d399c4 100644
--- a/model/Notification.php
+++ b/model/Notification.php
@@ -1,29 +1,42 @@
 <?php
 
 class EchoNotification {
-       protected $id = false;
-       protected $user = false;
-       protected $event = false;
-       protected $timestamp = false;
-       protected $readTimestamp = null;
+
+       /**
+        * @var User
+        */
+       protected $user;
+
+       /**
+        * @var EchoEvent
+        */
+       protected $event;
+
+       /**
+        * @var string
+        */
+       protected $timestamp;
+
+       /**
+        * @var string
+        */
+       protected $readTimestamp;
 
        /**
         * Do not use this constructor.
         */
-       protected function __construct() {
-       }
+       protected function __construct() {}
 
        /**
-        * Creates an EchoNotification object
-        * @param $info array Named arguments:
-        * event: (required) The EchoEvent being notified about.
-        * user: (required) The User being notified.
-        *
+        * Creates an EchoNotification object based on event and user
+        * @param $info array The following keys are required:
+        * - 'event' The EchoEvent being notified about.
+        * - 'user' The User being notified.
         * @throws MWException
         * @return EchoNotification
         */
-       public static function create( $info = array() ) {
-               $obj = new EchoNotification;
+       public static function create( array $info ) {
+               $obj = new EchoNotification();
                static $validFields = array( 'event', 'user' );
 
                $obj->timestamp = wfTimestampNow();
@@ -36,14 +49,12 @@
                        }
                }
 
-               if ( !$obj->user instanceof User &&
-                       !$obj->user instanceof StubObject
-               ) {
-                       throw new MWException( "Invalid user parameter: " . 
get_class( $obj->user ) );
+               if ( !$obj->user instanceof User && !$obj->user instanceof 
StubObject ) {
+                       throw new MWException( 'Invalid user parameter, 
expected: User/StubObject object' );
                }
 
                if ( !$obj->event instanceof EchoEvent ) {
-                       throw new MWException( "Invalid event parameter" );
+                       throw new MWException( 'Invalid event parameter, 
expected: EchoEvent object' );
                }
 
                $obj->insert();
@@ -82,4 +93,20 @@
        public function getUser() {
                return $this->user;
        }
+
+       /**
+        * Getter method
+        * @return string Notification creation timestamp
+        */
+       public function getTimestamp() {
+               return $this->timestamp;        
+       }
+
+       /**
+        * Getter method
+        * @return string|null Notification read timestamp 
+        */
+       public function getReadTimestamp() {
+               return $this->readTimestamp;    
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/52191
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb64de7034e7ff3c615dcee6fe814d64102f66cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to