apply scrutinizer & 优化代码

This commit is contained in:
yansongda 2017-08-19 22:00:16 +08:00
parent 8a6f991c88
commit cf574b7cf0
2 changed files with 24 additions and 6 deletions

View File

@ -106,6 +106,8 @@ abstract class Wechat implements GatewayInterface
$this->config['refund_fee'] = intval($this->config['refund_fee'] * 100);
$this->config['op_user_id'] = isset($this->config['op_user_id']) ?: $this->user_config->get('mch_id', '');
$this->unsetTradeTypeAndNotifyUrl();
return $this->getResult($this->gateway_refund, true);
}
@ -120,10 +122,10 @@ abstract class Wechat implements GatewayInterface
*/
public function close($out_trade_no = '')
{
unset($this->config['notify_url']);
unset($this->config['trade_type']);
$this->config['out_trade_no'] = $out_trade_no;
$this->unsetTradeTypeAndNotifyUrl();
return $this->getResult($this->gateway_close);
}
@ -139,11 +141,10 @@ abstract class Wechat implements GatewayInterface
*/
public function find($out_trade_no = '')
{
unset($this->config['notify_url']);
unset($this->config['trade_type']);
$this->config['out_trade_no'] = $out_trade_no;
$this->unsetTradeTypeAndNotifyUrl();
return $this->getResult($this->gateway_query);
}
@ -361,4 +362,21 @@ abstract class Wechat implements GatewayInterface
return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA), JSON_UNESCAPED_UNICODE), true);
}
/**
* 删除 trade_type and notify_url.
*
* @author yansongda <me@yansongda.cn>
*
* @version 2017-08-19
*
* @return boolean [description]
*/
protected function unsetTradeTypeAndNotifyUrl()
{
unset($this->config['notify_url']);
unset($this->config['trade_type']);
return true
}
}

View File

@ -54,7 +54,7 @@ class Pay
*
* @param string $driver [description]
*
* @return object [description]
* @return Pay [description]
*/
public function driver($driver)
{