Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,45 +79,48 @@ public static function getUri()
*/
public static function getData($extended = true)
{
switch (static::getMethod()) {
$input = null;
$method = static::getMethod();
$contentType = static::getHeader('Content-Type');

// map data
switch ($method) {
case Request::METHOD_GET:
return $_GET;
$input = $_GET;
break;

case Request::METHOD_POST:
$contentType = static::getHeader('Content-Type');

switch ($contentType) {
case 'application/x-www-form-urlencoded':
return $_POST;
$input = $_POST;
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this line for clarity purpose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep this empty line, yes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK


case 'application/json':
$input = file_get_contents('php://input');
switch ($contentType) {
case 'application/x-www-form-urlencoded':
if (null === $input) {
$content = file_get_contents('php://input');
parse_str($content, $input);
}

if (true !== $extended ||
true !== function_exists('json_decode')) {
return $input;
}
return $input;

$json = json_decode($input, true);
case 'application/json':
$input = file_get_contents('php://input');

if (JSON_ERROR_NONE !== json_last_error()) {
return $input;
}
if (true !== $extended ||
true !== function_exists('json_decode')) {
return $input;
}

return $json;
$json = json_decode($input, true);

default:
return file_get_contents('php://input');
if (JSON_ERROR_NONE !== json_last_error()) {
return $input;
}

break;

case Request::METHOD_PUT:
case Request::METHOD_PATCH:
return file_get_contents('php://input');
return $json;

default:
return null;
return file_get_contents('php://input');
}
}

Expand Down