summaryrefslogtreecommitdiff
path: root/src/Http/Request.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff /src/Http/Request.php
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
Diffstat (limited to 'src/Http/Request.php')
-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..c6a9e5ad
--- /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 !is_null($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()), '/');
+ }
+}