src/XmlParser.php
public function load($xmlString)
    {
        $data   =  $this->parserXml($xmlString);

        if (!isset($data['MsgType'])) {
            throw new \RuntimeException("can not found MsgType");
        }

        // event message
        if (WxReceive::MSG_TYPE_EVENT == $data['MsgType']) {
            $parser = new Event\Parser();
            return $parser->load($data);
        }

        // other message
        $parser = new Message\Parser();
        return $parser->load($data);
    }
public function load($xmlString)
    {
        $data   =  $this->parserXml($xmlString);

        if (!isset($data['MsgType'])) {
            throw new \RuntimeException("can not found MsgType");
        }

        // event message
        if (WxReceive::MSG_TYPE_EVENT == $data['MsgType']) {
            $parser = new Event\Parser();
            return $parser->load($data);
        }

        // other message
        $parser = new Message\Parser();
        return $parser->load($data);
    }
public function load ( $ xmlString ) { $ data = $ this -> parserXml ( $ xmlString ) ; if ( ! isset ( $ data [ 'MsgType' ] ) ) { throw new \ RuntimeException ( "can not found MsgType" ) ; } // event message if ( WxReceive :: MSG_TYPE_EVENT == $ data [ 'MsgType' ] ) { $ parser = new Event \ Parser ( ) ; return $ parser -> load ( $ data ) ; } // other message $ parser = new Message \ Parser ( ) ; return $ parser -> load ( $ data ) ; }
parse xml string which come from WeChat server
to WxReceiveMsg or WxReceiveEvent
@param $xmlString
@return WxReceive
parse xml string which come from WeChat server to WxReceiveMsg or WxReceiveEvent