Completed
Push — master ( 87d470...619388 )
by Wei
04:23
created
src/cache/JsonFileCacheProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@  discard block
 block discarded – undo
6 6
  * @author zhangv
7 7
  */
8 8
 namespace zhangv\wechat\pay\cache;
9
-class JsonFileCacheProvider implements CacheProvider{
9
+class JsonFileCacheProvider implements CacheProvider {
10 10
 	private $cacheDir = null;
11 11
 
12
-	public function __construct($cacheDir = null){
13
-		if(!$cacheDir) $this->cacheDir = __DIR__;
12
+	public function __construct($cacheDir = null) {
13
+		if (!$cacheDir) $this->cacheDir = __DIR__;
14 14
 		else $this->cacheDir = $cacheDir;
15 15
 	}
16 16
 
17
-	public function set($key,$jsonobj,$expireAt = null){
17
+	public function set($key, $jsonobj, $expireAt = null) {
18 18
 		$data = $jsonobj;
19 19
 		$data->expires_at = $expireAt;
20 20
 		$file = "{$this->cacheDir}/{$key}.json";
21
-		if($fp = @fopen($file, "w")){
21
+		if ($fp = @fopen($file, "w")) {
22 22
 			fwrite($fp, json_encode($data));
23 23
 			fclose($fp);
24 24
 		}
25 25
 	}
26 26
 
27
-	public function get($key){
27
+	public function get($key) {
28 28
 		$file = "{$this->cacheDir}/{$key}.json";
29 29
 		$cache = null;
30
-		if(file_exists($file)){
30
+		if (file_exists($file)) {
31 31
 			$cache = json_decode(file_get_contents($file));
32
-			if($cache->expires_at < time()){
32
+			if ($cache->expires_at < time()) {
33 33
 				$cache = null;
34 34
 				$this->clear($key);
35 35
 			}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		return $cache;
38 38
 	}
39 39
 
40
-	public function clear($key){
40
+	public function clear($key) {
41 41
 		$file = "{$this->cacheDir}/{$key}.json";
42 42
 		if (file_exists($file)) {
43 43
 			unlink($file);
Please login to merge, or discard this patch.
src/cache/CacheProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  */
8 8
 namespace zhangv\wechat\pay\cache;
9 9
 
10
-interface CacheProvider{
11
-	function set($key,$value,$expireAt);
10
+interface CacheProvider {
11
+	function set($key, $value, $expireAt);
12 12
 	function get($key);
13 13
 	function clear($key);
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/cache/RedisCacheProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
  * @author zhangv
7 7
  */
8 8
 namespace zhangv\wechat\pay\cache;
9
-class RedisCacheProvider implements CacheProvider{
9
+class RedisCacheProvider implements CacheProvider {
10 10
 	/** @var Redis */
11 11
 	private $redis = null;
12 12
 
13
-	public function __construct($redis = null){
13
+	public function __construct($redis = null) {
14 14
 		$this->redis = $redis;
15 15
 	}
16 16
 
17
-	public function set($key,$jsonobj,$expireAt){
17
+	public function set($key, $jsonobj, $expireAt) {
18 18
 		$data = $jsonobj;
19 19
 		$data->expires_at = $expireAt;
20 20
 		$this->redis->set($key, json_encode($data));
21 21
 	}
22 22
 
23
-	public function get($key){
23
+	public function get($key) {
24 24
 		return $this->redis->get($key);
25 25
 	}
26 26
 
27
-	public function clear($key){
27
+	public function clear($key) {
28 28
 		$this->redis->delete($key);
29 29
 	}
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/Mweb.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@
 block discarded – undo
35 35
 	 * @return string
36 36
 	 * @throws Exception
37 37
 	 */
38
-	public function getMwebUrl($body,$out_trade_no,$total_fee,$ext = null){
39
-		$data = ($ext && is_array($ext))?$ext:array();
38
+	public function getMwebUrl($body, $out_trade_no, $total_fee, $ext = null) {
39
+		$data = ($ext && is_array($ext)) ? $ext : array();
40 40
 		$data["body"]         = $body;
41 41
 		$data["out_trade_no"] = $out_trade_no;
42 42
 		$data["total_fee"]    = $total_fee;
43
-		$data["spbill_create_ip"] = isset($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:'';
43
+		$data["spbill_create_ip"] = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '';
44 44
 		$data["notify_url"]   = $this->config["notify_url"];
45 45
 		$data["trade_type"]   = self::TRADETYPE_MWEB;
46
-		if(!isset($this->config['h5_scene_info'])) throw new Exception('h5_scene_info should be configured');
46
+		if (!isset($this->config['h5_scene_info'])) throw new Exception('h5_scene_info should be configured');
47 47
 		$data["scene_info"]   = json_encode($this->config['h5_scene_info']);
48 48
 		$result = $this->unifiedOrder($data);
49 49
 		return $result["mweb_url"];
Please login to merge, or discard this patch.
src/service/Native.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@
 block discarded – undo
38 38
 	 * @return string
39 39
 	 * @throws Exception
40 40
 	 */
41
-	public function getCodeUrl($body,$out_trade_no,$total_fee,$product_id,$spbill_create_ip = null,$ext = null){
42
-		$data = ($ext && is_array($ext))?$ext:array();
41
+	public function getCodeUrl($body, $out_trade_no, $total_fee, $product_id, $spbill_create_ip = null, $ext = null) {
42
+		$data = ($ext && is_array($ext)) ? $ext : array();
43 43
 		$data["body"]         = $body;
44 44
 		$data["out_trade_no"] = $out_trade_no;
45 45
 		$data["total_fee"]    = $total_fee;
46
-		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["SERVER_ADDR"];
46
+		$data["spbill_create_ip"] = $spbill_create_ip ?: $_SERVER["SERVER_ADDR"];
47 47
 		$data["notify_url"]   = $this->config["notify_url"];
48 48
 		$data["trade_type"]   = self::TRADETYPE_NATIVE;
49
-		if(!$product_id) throw new Exception('product_id is required when trade_type is NATIVE');
49
+		if (!$product_id) throw new Exception('product_id is required when trade_type is NATIVE');
50 50
 		$data["product_id"]   = $product_id;
51 51
 		$result = $this->unifiedOrder($data);
52 52
 		return $result["code_url"];
Please login to merge, or discard this patch.
src/service/Jsapi.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@
 block discarded – undo
38 38
 	 * @return string
39 39
 	 * @throws \Exception
40 40
 	 */
41
-	public function getPrepayId($body,$out_trade_no,$total_fee,$openid,$spbill_create_ip = null,$ext = null) {
42
-		$data = ($ext && is_array($ext))?$ext:array();
41
+	public function getPrepayId($body, $out_trade_no, $total_fee, $openid, $spbill_create_ip = null, $ext = null) {
42
+		$data = ($ext && is_array($ext)) ? $ext : array();
43 43
 		$data["body"]         = $body;
44 44
 		$data["out_trade_no"] = $out_trade_no;
45 45
 		$data["total_fee"]    = $total_fee;
46
-		$data["spbill_create_ip"] = $spbill_create_ip?:$_SERVER["REMOTE_ADDR"];
46
+		$data["spbill_create_ip"] = $spbill_create_ip ?: $_SERVER["REMOTE_ADDR"];
47 47
 		$data["notify_url"]   = $this->config["notify_url"];
48 48
 		$data["trade_type"]   = WechatPay::TRADETYPE_JSAPI;
49
-		if(!$openid) throw new Exception('openid is required when trade_type is JSAPI');
50
-		$data["openid"]   = $openid;
49
+		if (!$openid) throw new Exception('openid is required when trade_type is JSAPI');
50
+		$data["openid"] = $openid;
51 51
 		$result = $this->unifiedOrder($data);
52 52
 		return $result["prepay_id"];
53 53
 	}
Please login to merge, or discard this patch.
src/service/Micro.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return array
39 39
 	 * @throws Exception
40 40
 	 */
41
-	public function microPay($body,$out_trade_no,$total_fee,$spbill_create_ip,$auth_code,$ext = array()){
42
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
41
+	public function microPay($body, $out_trade_no, $total_fee, $spbill_create_ip, $auth_code, $ext = array()) {
42
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
43 43
 		$data["appid"] = $this->config["app_id"];
44 44
 		$data["body"]         = $body;
45 45
 		$data["out_trade_no"] = $out_trade_no;
46 46
 		$data["total_fee"]    = $total_fee;
47 47
 		$data["spbill_create_ip"] = $spbill_create_ip;
48 48
 		$data["auth_code"] = $auth_code;
49
-		return $this->post(self::URL_MICROPAY,$data,true);
49
+		return $this->post(self::URL_MICROPAY, $data, true);
50 50
 	}
51 51
 
52 52
 	/**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 * @return mixed
56 56
 	 * @throws Exception
57 57
 	 */
58
-	public function authCodeToOpenId($auth_code){
58
+	public function authCodeToOpenId($auth_code) {
59 59
 		$data = array();
60 60
 		$data["appid"] = $this->config["app_id"];
61 61
 		$data["auth_code"] = $auth_code;
62
-		return $this->post(self::URL_AUTHCODETOOPENID,$data,false);
62
+		return $this->post(self::URL_AUTHCODETOOPENID, $data, false);
63 63
 	}
64 64
 
65 65
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @return array
70 70
 	 * @throws Exception
71 71
 	 */
72
-	public function reverseByOutTradeNo($out_trade_no){
72
+	public function reverseByOutTradeNo($out_trade_no) {
73 73
 		$data = array();
74 74
 		$data["appid"] = $this->config["app_id"];
75 75
 		$data["out_trade_no"] = $out_trade_no;
76
-		return $this->post(self::URL_REVERSE, $data,true);
76
+		return $this->post(self::URL_REVERSE, $data, true);
77 77
 	}
78 78
 
79 79
 	/**
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @return array
83 83
 	 * @throws Exception
84 84
 	 */
85
-	public function reverseByTransactionId($transaction_id){
85
+	public function reverseByTransactionId($transaction_id) {
86 86
 		$data = array();
87 87
 		$data["appid"] = $this->config["app_id"];
88 88
 		$data["transaction_id"] = $transaction_id;
89
-		return $this->post(self::URL_REVERSE, $data,true);
89
+		return $this->post(self::URL_REVERSE, $data, true);
90 90
 	}
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/Coupon.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * @return array
23 23
 	 * @throws Exception
24 24
 	 */
25
-	public function sendCoupon($coupon_stock_id,$open_id,$partner_trade_no,$op_user_id = '',$ext = array()){
26
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
25
+	public function sendCoupon($coupon_stock_id, $open_id, $partner_trade_no, $op_user_id = '', $ext = array()) {
26
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
27 27
 		$data["partner_trade_no"] = $partner_trade_no;
28 28
 		$data["coupon_stock_id"] = $coupon_stock_id;
29 29
 		$data["openid_count"] = 1;
30 30
 		$data["open_id"] = $open_id;
31 31
 		$data["op_user_id"] = $op_user_id;
32
-		return $this->post(self::URL_SEND_COUPON,$data,true);
32
+		return $this->post(self::URL_SEND_COUPON, $data, true);
33 33
 	}
34 34
 
35 35
 	/**
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 * @return array
40 40
 	 * @throws Exception
41 41
 	 */
42
-	public function queryCouponStock($coupon_stock_id,$op_user_id = ''){
42
+	public function queryCouponStock($coupon_stock_id, $op_user_id = '') {
43 43
 		$data = array();
44 44
 		$data["coupon_stock_id"] = $coupon_stock_id;
45 45
 		$data["op_user_id"] = $op_user_id;
46
-		return $this->post(self::URL_QUERY_COUPON_STOCK,$data,false);
46
+		return $this->post(self::URL_QUERY_COUPON_STOCK, $data, false);
47 47
 	}
48 48
 
49 49
 	/**
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	 * @return array
57 57
 	 * @throws Exception
58 58
 	 */
59
-	public function queryCouponsInfo($coupon_id,$open_id,$stock_id,$op_user_id = '',$ext = array()){
60
-		$data = (!empty($ext) && is_array($ext))?$ext:array();
59
+	public function queryCouponsInfo($coupon_id, $open_id, $stock_id, $op_user_id = '', $ext = array()) {
60
+		$data = (!empty($ext) && is_array($ext)) ? $ext : array();
61 61
 		$data["coupon_id"] = $coupon_id;
62 62
 		$data["stock_id"] = $stock_id;
63 63
 		$data["open_id"] = $open_id;
64 64
 		$data["op_user_id"] = $op_user_id;
65
-		return $this->post(self::URL_QUERY_COUPON_INFO,$data,false);
65
+		return $this->post(self::URL_QUERY_COUPON_INFO, $data, false);
66 66
 	}
67 67
 
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/App.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 * @throws Exception
39 39
 	 */
40
-	public function getPrepayId($body,$out_trade_no,$total_fee,$spbill_create_ip,$ext = null) {
41
-		$data = ($ext && is_array($ext))?$ext:array();
40
+	public function getPrepayId($body, $out_trade_no, $total_fee, $spbill_create_ip, $ext = null) {
41
+		$data = ($ext && is_array($ext)) ? $ext : array();
42 42
 		$data["body"]         = $body;
43 43
 		$data["out_trade_no"] = $out_trade_no;
44 44
 		$data["total_fee"]    = $total_fee;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$data["timestamp"] = time();
64 64
 		$data["noncestr"]  = $this->getNonceStr();
65 65
 		$data["appid"] = $this->config["app_id"];
66
-		$data["sign"]   = $this->sign($data);
66
+		$data["sign"] = $this->sign($data);
67 67
 		return $data;
68 68
 	}
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.