From ab1a4760ed5b35cf58fc6f3f4e3c31be4cff17f2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Mon, 22 Sep 2014 14:31:12 +0200 Subject: Basic prototype to handle Github webhooks --- app/Model/Task.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/Model/Task.php') diff --git a/app/Model/Task.php b/app/Model/Task.php index 262e8d76..8708f128 100644 --- a/app/Model/Task.php +++ b/app/Model/Task.php @@ -696,4 +696,22 @@ class Task extends Base return false; } + + /** + * Get a the task id from a text + * + * Example: "Fix bug #1234" will return 1234 + * + * @access public + * @param string $message Text + * @return integer + */ + public function getTaskIdFromText($message) + { + if (preg_match('!#(\d+)!i', $message, $matches) && isset($matches[1])) { + return $matches[1]; + } + + return 0; + } } -- cgit v1.2.3