Пример #1
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'Event', 'EventKey', 'Ticket');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     $validtated = $validator->validate($options);
     parent::__construct($validtated);
 }
Пример #2
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'Event', 'Latitude', 'Longitude', 'Precision');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     $validtated = $validator->validate($options);
     $this->setOptions($validtated);
 }
Пример #3
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'PicUrl', 'MediaId', 'MsgId');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     $validtated = $validator->validate($options);
     $this->setOptions($validtated);
 }
Пример #4
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'Location_X', 'Location_Y', 'Scale', 'Label', 'MsgId');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     $validtated = $validator->validate($options);
     parent::__construct($validtated);
 }
Пример #5
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'Title', 'Description', 'Url', 'MsgId');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     $validtated = $validator->validate($options);
     parent::__construct($validtated);
 }
Пример #6
0
 /**
  * 构造方法
  */
 public function __construct(array $options = array())
 {
     $required = array('ToUserName', 'FromUserName', 'CreateTime', 'MsgType', 'Event');
     $defined = array_merge($required, array('EventKey'));
     $validator = new OptionValidator();
     $validator->setRequired($required)->setDefined($defined);
     $validtated = $validator->validate($options);
     $this->setOptions($validtated);
 }
Пример #7
0
 /**
  * 检测本次请求是有有效
  */
 public function isValid()
 {
     if (empty($this->options)) {
         $this->error = 'Invalid Request';
         return false;
     }
     $required = array('appid', 'bank_type', 'cash_fee', 'fee_type', 'is_subscribe', 'mch_id', 'nonce_str', 'openid', 'out_trade_no', 'result_code', 'return_code', 'sign', 'time_end', 'total_fee', 'trade_type', 'transaction_id');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     try {
         $validator->validate($this->options);
     } catch (\InvalidArgumentException $e) {
         $this->error = $e->getMessage();
         return false;
     }
     return true;
 }
Пример #8
0
 /**
  * 检测本次请求是有有效
  */
 public function isValid()
 {
     if (empty($this->options)) {
         $this->error = 'Invalid Request';
         return false;
     }
     $required = array('appid', 'openid', 'mch_id', 'is_subscribe', 'nonce_str', 'product_id', 'sign');
     $validator = new OptionValidator();
     $validator->setRequired($required);
     try {
         $validator->validate($this->options);
     } catch (\InvalidArgumentException $e) {
         $this->error = $e->getMessage();
         return false;
     }
     return true;
 }