From 541fff199aed3140f045778b80d9e5713577d047 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 21 Jan 2019 23:06:25 +0100 Subject: [PATCH] Put PHP paste request into own function --- lib/Request.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Request.php b/lib/Request.php index 431542a..1487b4b 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -72,6 +72,19 @@ class Request */ private $_isJsonApi = false; + /** + * Return the paste ID of the current paste. + * + * @access private + * @return string + */ + private function getPasteId() + { + return preg_match( + '/[a-f0-9]{16}/', $_SERVER['QUERY_STRING'], $match + ) ? $match[0] : 'invalid id'; + } + /** * Constructor * @@ -100,9 +113,7 @@ class Request array_key_exists('QUERY_STRING', $_SERVER) && !empty($_SERVER['QUERY_STRING']) ) { - $this->_params['pasteid'] = preg_match( - '/[a-f0-9]{16}/', $_SERVER['QUERY_STRING'], $match - ) ? $match[0] : 'invalid id'; + $this->_params['pasteid'] = $this->getPasteId(); } // prepare operation, depending on current parameters