From 97bedfaa0814e8389dce3b80d57057d61a9ac770 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 6 Apr 2016 11:18:28 +0200 Subject: [PATCH] lib: Provide ticket pattern class for ticket hooks refs #10909 --- .../Application/Hook/Ticket/TicketPattern.php | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 library/Icinga/Application/Hook/Ticket/TicketPattern.php diff --git a/library/Icinga/Application/Hook/Ticket/TicketPattern.php b/library/Icinga/Application/Hook/Ticket/TicketPattern.php new file mode 100644 index 000000000..8116ca6be --- /dev/null +++ b/library/Icinga/Application/Hook/Ticket/TicketPattern.php @@ -0,0 +1,152 @@ +match[$offset]); + } + + /** + * {@inheritdoc} + */ + public function offsetGet($offset) + { + return array_key_exists($offset, $this->match) ? $this->match[$offset] : null; + } + + /** + * {@inheritdoc} + */ + public function offsetSet($offset, $value) + { + if ($offset === null) { + $this->match[] = $value; + } else { + $this->match[$offset] = $value; + } + } + + /** + * {@inheritdoc} + */ + public function offsetUnset($offset) + { + unset($this->match[$offset]); + } + + + /** + * Get the result of a performed ticket match + * + * @return array + */ + public function getMatch() + { + return $this->match; + } + + /** + * Set the result of a performed ticket match + * + * @param array $match + * + * @return $this + */ + public function setMatch(array $match) + { + $this->match = $match; + return $this; + } + + /** + * Get the name of the TTS integration + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name of the TTS integration + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Get the ticket pattern + * + * @return string + */ + public function getPattern() + { + return $this->pattern; + } + + /** + * Set the ticket pattern + * + * @param string $pattern + * + * @return $this + */ + public function setPattern($pattern) + { + $this->pattern = $pattern; + return $this; + } + + /** + * Whether the integration is properly configured, i.e. the pattern and the URL are not empty + * + * @return bool + */ + public function isValid() + { + return ! empty($this->pattern); + } +}