Code style fixes
This commit is contained in:
parent
6c4c669492
commit
0868eb9c69
63 changed files with 1413 additions and 1494 deletions
|
|
@ -5,18 +5,18 @@ namespace b8\Http;
|
|||
class Request
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $params = array();
|
||||
* @var array
|
||||
*/
|
||||
protected $params = [];
|
||||
|
||||
/**
|
||||
* Request data.
|
||||
*/
|
||||
protected $data = array();
|
||||
* Request data.
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Set up the request.
|
||||
*/
|
||||
* Set up the request.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parseInput();
|
||||
|
|
@ -40,7 +40,7 @@ class Request
|
|||
}
|
||||
|
||||
// Remove index.php from the URL if it is present:
|
||||
$path = str_replace(array('/index.php', 'index.php'), '', $path);
|
||||
$path = str_replace(['/index.php', 'index.php'], '', $path);
|
||||
|
||||
// Also cut out the query string:
|
||||
$path = explode('?', $path);
|
||||
|
|
@ -50,22 +50,20 @@ class Request
|
|||
}
|
||||
|
||||
/**
|
||||
* Parse incoming variables, incl. $_GET, $_POST and also reads php://input for PUT/DELETE.
|
||||
*/
|
||||
* Parse incoming variables, incl. $_GET, $_POST and also reads php://input for PUT/DELETE.
|
||||
*/
|
||||
protected function parseInput()
|
||||
{
|
||||
$params = $_REQUEST;
|
||||
|
||||
if(!isset($_SERVER['REQUEST_METHOD']) || in_array($_SERVER['REQUEST_METHOD'], array('PUT', 'DELETE')))
|
||||
{
|
||||
if (!isset($_SERVER['REQUEST_METHOD']) || in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'DELETE'])) {
|
||||
$vars = file_get_contents('php://input');
|
||||
|
||||
if(!is_string($vars) || strlen(trim($vars)) === 0)
|
||||
{
|
||||
if (!is_string($vars) || strlen(trim($vars)) === 0) {
|
||||
$vars = '';
|
||||
}
|
||||
|
||||
$inputData = array();
|
||||
$inputData = [];
|
||||
parse_str($vars, $inputData);
|
||||
|
||||
$params = array_merge($params, $inputData);
|
||||
|
|
@ -75,17 +73,17 @@ class Request
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all request parameters.
|
||||
* @return array
|
||||
*/
|
||||
* Returns all request parameters.
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a specific request parameter, or a default value if not set.
|
||||
*/
|
||||
* Return a specific request parameter, or a default value if not set.
|
||||
*/
|
||||
public function getParam($key, $default = null)
|
||||
{
|
||||
if (isset($this->params[$key])) {
|
||||
|
|
@ -96,24 +94,24 @@ class Request
|
|||
}
|
||||
|
||||
/**
|
||||
* Set or override a request parameter.
|
||||
*/
|
||||
* Set or override a request parameter.
|
||||
*/
|
||||
public function setParam($key, $value = null)
|
||||
{
|
||||
$this->params[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an array of request parameters.
|
||||
*/
|
||||
* Set an array of request parameters.
|
||||
*/
|
||||
public function setParams(array $params)
|
||||
{
|
||||
$this->params = array_merge($this->params, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-set a specific parameter.
|
||||
*/
|
||||
* Un-set a specific parameter.
|
||||
*/
|
||||
public function unsetParam($key)
|
||||
{
|
||||
unset($this->params[$key]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue