summaryrefslogtreecommitdiff
path: root/src/Http
diff options
context:
space:
mode:
Diffstat (limited to 'src/Http')
-rw-r--r--src/Http/Request.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Http/Request.php b/src/Http/Request.php
new file mode 100644
index 00000000..e7850c8b
--- /dev/null
+++ b/src/Http/Request.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
+
+class Request extends SymfonyRequest
+{
+ /**
+ * Get POST input
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function postData($key, $default = null)
+ {
+ return $this->request->get($key, $default);
+ }
+
+ /**
+ * Get input data
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function input($key, $default = null)
+ {
+ return $this->get($key, $default);
+ }
+
+ /**
+ * Checks if the input exists
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function has($key)
+ {
+ $value = $this->input($key);
+
+ return !empty($value);
+ }
+
+ /**
+ * Get the requested path
+ *
+ * @return string
+ */
+ public function path()
+ {
+ $pattern = trim($this->getPathInfo(), '/');
+
+ return $pattern == '' ? '/' : $pattern;
+ }
+
+ /**
+ * Return the current URL
+ *
+ * @return string
+ */
+ public function url()
+ {
+ return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
+ }
+}