| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | 
							- <?php
 
- /*
 
-  * To change this license header, choose License Headers in Project Properties.
 
-  * To change this template file, choose Tools | Templates
 
-  * and open the template in the editor.
 
-  */
 
- namespace app\common\api;
 
- /**
 
-  * Description of Response
 
-  *
 
-  * @author sgq
 
-  */
 
- class Response{
 
-     public $code, $msg, $obj;
 
-     const SUCCESS = 200;
 
-     const ERROR = 500;
 
-     public function __construct($code, $msg, $obj = null) {
 
-         $this->setCode($code);
 
-         $this->setMsg($msg);
 
-         $this->obj = $obj;
 
-     }
 
-     public function __set($name, $value) {
 
-         if (property_exists($this, $name)) {
 
-             $this->$name = $value;
 
-         } else {
 
-             throw new \Exception("Property '$name' does not exist in 'Response' class.");
 
-         }
 
-     }
 
-     public function __get($name) {
 
-         if (property_exists($this, $name)) {
 
-             return $this->$name;
 
-         } else {
 
-             throw new \Exception("Property '$name' does not exist in 'Response' class.");
 
-         }
 
-     }
 
-     public function __isset($name) {
 
-         return property_exists($this, $name);
 
-     }
 
-     public function setCode($code) {
 
-         if (is_int($code)) {
 
-             $this->code = $code;
 
-         } else {
 
-             throw new \Exception("Invalid code. Please provide an integer.");
 
-         }
 
-     }
 
-     public function setMsg($msg) {
 
-         if (is_string($msg)) {
 
-             $this->msg = $msg;
 
-         } else {
 
-             throw new \Exception("Invalid msg. Please provide an string.");
 
-         }
 
-     }
 
- }
 
 
  |