Skip to content

Commit

Permalink
tweak code. (#640)
Browse files Browse the repository at this point in the history
* tweak code.

* Fix styles.

* Remove unused method.
  • Loading branch information
mingyoung authored and overtrue committed Apr 7, 2017
1 parent 9bb76a0 commit 69a222e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
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);
}
}

0 comments on commit 69a222e

Please sign in to comment.