summaryrefslogtreecommitdiff
path: root/app/Core/Http/Request.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Core/Http/Request.php')
-rw-r--r--app/Core/Http/Request.php49
1 files changed, 41 insertions, 8 deletions
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index c626f5b2..da95f2d4 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -42,6 +42,16 @@ class Request extends Base
}
/**
+ * Set GET parameters
+ *
+ * @param array $params
+ */
+ public function setParams(array $params)
+ {
+ $this->get = array_merge($this->get, $params);
+ }
+
+ /**
* Get query string string parameter
*
* @access public
@@ -147,6 +157,17 @@ class Request extends Base
}
/**
+ * Return HTTP method
+ *
+ * @access public
+ * @return bool
+ */
+ public function getMethod()
+ {
+ return $this->getServerVariable('REQUEST_METHOD');
+ }
+
+ /**
* Return true if the HTTP request is sent with the POST method
*
* @access public
@@ -154,7 +175,7 @@ class Request extends Base
*/
public function isPost()
{
- return isset($this->server['REQUEST_METHOD']) && $this->server['REQUEST_METHOD'] === 'POST';
+ return $this->getServerVariable('REQUEST_METHOD') === 'POST';
}
/**
@@ -203,7 +224,7 @@ class Request extends Base
public function getHeader($name)
{
$name = 'HTTP_'.str_replace('-', '_', strtoupper($name));
- return isset($this->server[$name]) ? $this->server[$name] : '';
+ return $this->getServerVariable($name);
}
/**
@@ -214,18 +235,18 @@ class Request extends Base
*/
public function getRemoteUser()
{
- return isset($this->server[REVERSE_PROXY_USER_HEADER]) ? $this->server[REVERSE_PROXY_USER_HEADER] : '';
+ return $this->getServerVariable(REVERSE_PROXY_USER_HEADER);
}
/**
- * Returns current request's query string, useful for redirecting
+ * Returns query string
*
* @access public
* @return string
*/
public function getQueryString()
{
- return isset($this->server['QUERY_STRING']) ? $this->server['QUERY_STRING'] : '';
+ return $this->getServerVariable('QUERY_STRING');
}
/**
@@ -236,7 +257,7 @@ class Request extends Base
*/
public function getUri()
{
- return isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
+ return $this->getServerVariable('REQUEST_URI');
}
/**
@@ -269,7 +290,7 @@ class Request extends Base
);
foreach ($keys as $key) {
- if (! empty($this->server[$key])) {
+ if ($this->getServerVariable($key) !== '') {
foreach (explode(',', $this->server[$key]) as $ipAddress) {
return trim($ipAddress);
}
@@ -287,6 +308,18 @@ class Request extends Base
*/
public function getStartTime()
{
- return isset($this->server['REQUEST_TIME_FLOAT']) ? $this->server['REQUEST_TIME_FLOAT'] : 0;
+ return $this->getServerVariable('REQUEST_TIME_FLOAT') ?: 0;
+ }
+
+ /**
+ * Get server variable
+ *
+ * @access public
+ * @param string $variable
+ * @return string
+ */
+ public function getServerVariable($variable)
+ {
+ return isset($this->server[$variable]) ? $this->server[$variable] : '';
}
}