<?php

/**
 * Description of Resp
 * 应答体
 * @author jgao
 */
class Resp {
    //put your code here

    /**
     * 应答数据
     * @var type 
     */
    public $data = null;

    /**
     * 错误码
     * @var type 
     */
    public $err = 0;

    /**
     * 错误消息
     * @var type 
     */
    public $errMsg = "";

    function stringify() {
        return json_encode($this);
    }

    /**
     * 
     * @param type $data
     * @return \Resp
     */
    static function ret($data) {
        $resp = new Resp();
        $resp->data = $data;
        return $resp;
    }

    /**
     * 
     * @param type $err
     * @param type $msg
     * @return \Resp
     */
    static function err($err, $msg) {
        $resp = new Resp();
        $resp->err = $err;
        $resp->errMsg = $msg;
        return $resp;
    }

}
