From 8a1592fd126d25c6c8c501c09d1825a60ad42a82 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 3 Sep 2015 16:27:50 +0200 Subject: [PATCH] monitoring/lib: Add Acknowledgement object refs #9674 --- .../Monitoring/Object/Acknowledgement.php | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Object/Acknowledgement.php diff --git a/modules/monitoring/library/Monitoring/Object/Acknowledgement.php b/modules/monitoring/library/Monitoring/Object/Acknowledgement.php new file mode 100644 index 000000000..de405823b --- /dev/null +++ b/modules/monitoring/library/Monitoring/Object/Acknowledgement.php @@ -0,0 +1,215 @@ +setProperties($properties); + } + } + + /** + * Get the author of the acknowledgement + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set the author of the acknowledgement + * + * @param string $author + * + * @return $this + */ + public function setAuthor($author) + { + $this->author = (string) $author; + return $this; + } + + /** + * Get the comment of the acknowledgement + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set the comment of the acknowledgement + * + * @param string $comment + * + * @return $this + */ + public function setComment($comment) + { + $this->comment = (string) $comment; + + return $this; + } + + /** + * Get the entry time of the acknowledgement + * + * @return int + */ + public function getEntryTime() + { + return $this->entryTime; + } + + /** + * Set the entry time of the acknowledgement + * + * @param int $entryTime + * + * @return $this + */ + public function setEntryTime($entryTime) + { + $this->entryTime = (int) $entryTime; + + return $this; + } + + /** + * Get the expiration time of the acknowledgement + * + * @return int|null + */ + public function getExpirationTime() + { + return $this->expirationTime; + } + + /** + * Set the expiration time of the acknowledgement + * + * @param int|null $expirationTime Unix timestamp + * + * @return $this + */ + public function setExpirationTime($expirationTime = null) + { + $this->expirationTime = $expirationTime !== null ? (int) $expirationTime : null; + + return $this; + } + + /** + * Get whether the acknowledgement is sticky + * + * @return bool + */ + public function getSticky() + { + return $this->sticky; + } + + /** + * Set whether the acknowledgement is sticky + * + * @param bool $sticky + * + * @return $this + */ + public function setSticky($sticky = true) + { + $this->sticky = (bool) $sticky; + return $this; + } + + /** + * Get whether the acknowledgement expires + * + * @return bool + */ + public function expires() + { + return $this->expirationTime !== null; + } + + /** + * Set the properties of the acknowledgement + * + * @param array|object|Traversable $properties + * + * @return $this + * @throws InvalidArgumentException If the type of the given properties is invalid + */ + public function setProperties($properties) + { + if (! is_array($properties) && ! is_object($properties) && ! $properties instanceof Traversable) { + throw new InvalidArgumentException('Properties must be either an array or an instance of Traversable'); + } + foreach ($properties as $name => $value) { + $setter = 'set' . ucfirst(String::cname($name)); + if (method_exists($this, $setter)) { + $this->$setter($value); + } + } + return $this; + } +}