diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-11-18 16:27:48 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-11-23 11:41:48 +0100 |
commit | a370c290685615a79c38aac98b5a811ca0e7bf1d (patch) | |
tree | 0d8d354600233cad0fa679a3560cdc27e060a2b8 /lib | |
parent | 43391f8f47d82eca4605ed9255d551ca3a9cbf33 (diff) | |
download | nextcloud-server-a370c290685615a79c38aac98b5a811ca0e7bf1d.tar.gz nextcloud-server-a370c290685615a79c38aac98b5a811ca0e7bf1d.zip |
Use a DateTime object instead of a timestamp
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/notification/inotification.php | 14 | ||||
-rw-r--r-- | lib/private/notification/notification.php | 31 |
2 files changed, 23 insertions, 22 deletions
diff --git a/lib/private/notification/inotification.php b/lib/private/notification/inotification.php index a8bf5b110ab..b79b7f6d9d3 100644 --- a/lib/private/notification/inotification.php +++ b/lib/private/notification/inotification.php @@ -61,18 +61,18 @@ interface INotification { public function getUser(); /** - * @param int $timestamp + * @param \DateTime $dateTime * @return $this - * @throws \InvalidArgumentException if the timestamp are invalid - * @since 8.2.0 + * @throws \InvalidArgumentException if the $dateTime is invalid + * @since 9.0.0 */ - public function setTimestamp($timestamp); + public function setDateTime(\DateTime $dateTime); /** - * @return int - * @since 8.2.0 + * @return \DateTime + * @since 9.0.0 */ - public function getTimestamp(); + public function getDateTime(); /** * @param string $type diff --git a/lib/private/notification/notification.php b/lib/private/notification/notification.php index 01df659d4a1..a22d5446f45 100644 --- a/lib/private/notification/notification.php +++ b/lib/private/notification/notification.php @@ -29,8 +29,8 @@ class Notification implements INotification { /** @var string */ protected $user; - /** @var int */ - protected $timestamp; + /** @var \DateTime */ + protected $dateTime; /** @var string */ protected $objectType; @@ -80,7 +80,8 @@ class Notification implements INotification { public function __construct() { $this->app = ''; $this->user = ''; - $this->timestamp = 0; + $this->dateTime = new \DateTime(); + $this->dateTime->setTimestamp(0); $this->objectType = ''; $this->objectId = 0; $this->subject = ''; @@ -140,25 +141,25 @@ class Notification implements INotification { } /** - * @param int $timestamp + * @param \DateTime $dateTime * @return $this - * @throws \InvalidArgumentException if the timestamp is invalid - * @since 8.2.0 + * @throws \InvalidArgumentException if the $dateTime is invalid + * @since 9.0.0 */ - public function setTimestamp($timestamp) { - if (!is_int($timestamp)) { - throw new \InvalidArgumentException('The given timestamp is invalid'); + public function setDateTime(\DateTime $dateTime) { + if ($dateTime->getTimestamp() === 0) { + throw new \InvalidArgumentException('The given date time is invalid'); } - $this->timestamp = $timestamp; + $this->dateTime = $dateTime; return $this; } /** - * @return int - * @since 8.2.0 + * @return \DateTime + * @since 9.0.0 */ - public function getTimestamp() { - return $this->timestamp; + public function getDateTime() { + return $this->dateTime; } /** @@ -438,7 +439,7 @@ class Notification implements INotification { && $this->getUser() !== '' && - $this->getTimestamp() !== 0 + $this->getDateTime()->getTimestamp() !== 0 && $this->getObjectType() !== '' && |