Skip to content

Commit b6e0492

Browse files
committed
allow access to raw and content methods of request object
1 parent 7029f98 commit b6e0492

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/Request.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function __construct($args = []) {
2323
if ($this->_contentType() === 'application/x-www-form-urlencoded' || !$this->_contentType()) {
2424
$this->_properties = $_GET;
2525
} elseif ($this->_contentType() === 'application/json') {
26-
$this->_properties = $this->_getRawRequest();
26+
$this->_properties = $this->raw();
2727
}
2828
break;
2929

3030
case 'POST':
3131
if ($this->_contentType() === 'application/json') {
32-
$this->_properties = json_decode($this->_getContent(), 'array');
32+
$this->_properties = json_decode($this->content(), 'array');
3333
// } elseif ($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
3434
} else {
3535
$this->_properties = $_POST;
@@ -40,10 +40,10 @@ public function __construct($args = []) {
4040
case 'DELETE':
4141
default:
4242
if ($this->_contentType() === 'application/x-www-form-urlencoded') {
43-
parse_str($this->_getContent(), $this->_properties);
43+
parse_str($this->content(), $this->_properties);
4444

4545
} elseif ($this->_contentType() === 'application/json') {
46-
$content = $this->_getContent();
46+
$content = $this->content();
4747
$request = json_decode($content,'array');
4848
if (!$request) {
4949
$this->_properties = false;
@@ -121,7 +121,7 @@ public function path($url = null) {
121121
return $this->_path;
122122
}
123123

124-
private function _getContent() {
124+
public function content() {
125125
if (!isset($this->_content)) {
126126
if (strlen(trim($this->_content = file_get_contents(!is_null($_ENV['TESTS_PHP_INPUT']) ? $_ENV['TESTS_PHP_INPUT'] : 'php://input'))) === 0) {
127127
$this->_content = false;
@@ -130,7 +130,7 @@ private function _getContent() {
130130
return $this->_content;
131131
}
132132

133-
private function _getRawRequest() {
133+
public function raw() {
134134
if (!isset($this->_rawRequest)) {
135135
$request = trim($_SERVER['REQUEST_URI']);
136136
$request = substr($request,strpos($request,'?')+1);

0 commit comments

Comments
 (0)