Skip to content
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
15 changes: 11 additions & 4 deletions src/Lib/Http/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,24 @@ public function getBody(): array
/**
* Returns body data by key
*
* @param string $key
* @param string $key
* @param mixed $default
* @return mixed
*/
public function getBodyData(string $key, $default = null)
{
return array_key_exists($key, $this->body) ? $this->body[$key] : $default;
// return array_key_exists($key, $this->body) ? json_encode($this->body[$key]) : $default;
if (array_key_exists($key, $this->body)) {
if (is_string($this->body[$key])) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this.body is array of strings, so it will always be string.

return $this->body[$key];
} else {
return json_encode($this->body[$key]);
}
} else {
return $default;
}
}



/**
* Returns body content type
*
Expand Down