Thenbsp\Wechat\Bridge\Serializer::parse PHP Метод

parse() публичный статический Метод

xml/json to array
public static parse ( $string )
    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;
    }

Usage Example

Пример #1
0
 /**
  * 构造方法
  */
 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);
 }
All Usage Examples Of Thenbsp\Wechat\Bridge\Serializer::parse