Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak code. #640

Merged
merged 3 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
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
16 changes: 3 additions & 13 deletions src/Server/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use EasyWeChat\Message\Text;
use EasyWeChat\Support\Collection;
use EasyWeChat\Support\Log;
use EasyWeChat\Support\Str;
use EasyWeChat\Support\XML;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -347,16 +346,6 @@ public function getMessage()
return $message;
}

/**
* Get the collected request message.
*
* @return Collection
*/
public function getCollectedMessage()
{
return new Collection($this->getMessage());
}

/**
* Handle request.
*
Expand Down Expand Up @@ -460,8 +449,9 @@ protected function parseMessageFromRequest($content)
{
$content = strval($content);

if (Str::isJson($content)) {
return Str::json2Array($content);
$arrayable = json_decode($content, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $arrayable;
}

if ($this->isSafeMode()) {
Expand Down
10 changes: 0 additions & 10 deletions src/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,4 @@ public static function studly($value)

return static::$studlyCache[$key] = str_replace(' ', '', $value);
}

public static function isJson($value)
{
return json_decode($value) !== null;
}

public static function json2Array($value)
{
return json_decode($value, true);
}
}