public static function parse($string)
{
if (static::isJSON($string)) {
$result = static::jsonDecode($string);
} elseif (static::isXML($string)) {
$result = static::xmlDecode($string);
} else {
throw new \InvalidArgumentException(sprintf('Unable to parse: %s', (string) $string));
}
return (array) $result;
}
/** * 构造方法 */ public function __construct(Request $request = null) { $request = $request ?: Request::createFromGlobals(); $content = $request->getContent(); try { $options = Serializer::parse($content); } catch (\InvalidArgumentException $e) { $options = array(); } parent::__construct($options); }