engelsystem/src/Http/Request.php

68 lines
1.2 KiB
PHP
Raw Normal View History

<?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)
{
2017-11-19 15:16:01 +01:00
$value = $this->input($key);
2017-11-19 15:16:01 +01:00
return !is_null($value);
}
2017-08-28 16:21:10 +02:00
/**
* Get the requested path
*
* @return string
*/
public function path()
{
$pattern = trim($this->getPathInfo(), '/');
2017-08-28 16:21:10 +02:00
return $pattern == '' ? '/' : $pattern;
2017-08-28 16:21:10 +02:00
}
/**
* Return the current URL
*
2017-08-28 16:21:10 +02:00
* @return string
*/
public function url()
2017-08-28 16:21:10 +02:00
{
return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
2017-08-28 16:21:10 +02:00
}
}