Skip to content

Commit

Permalink
Apply fixes from StyleCI (overtrue#208)
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
overtrue authored Jul 31, 2019
1 parent fc4ad37 commit 25140e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/Gateways/YunxinGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class YunxinGateway extends Gateway
* Send a short message.
*
* @param \Overtrue\EasySms\Contracts\PhoneNumberInterface $to
* @param \Overtrue\EasySms\Contracts\MessageInterface $message
* @param \Overtrue\EasySms\Support\Config $config
* @param \Overtrue\EasySms\Contracts\MessageInterface $message
* @param \Overtrue\EasySms\Support\Config $config
*
* @return array
*
Expand All @@ -56,9 +56,11 @@ public function send(PhoneNumberInterface $to, MessageInterface $message, Config
switch ($action) {
case 'sendCode':
$params = $this->buildSendCodeParams($to, $message, $config);

break;
case 'verifyCode':
$params = $this->buildVerifyCodeParams($to, $message);

break;
default:
throw new GatewayErrorException(sprintf('action: %s not supported', $action), 0);
Expand All @@ -72,6 +74,7 @@ public function send(PhoneNumberInterface $to, MessageInterface $message, Config
if (!isset($result['code']) || self::SUCCESS_CODE !== $result['code']) {
$code = isset($result['code']) ? $result['code'] : 0;
$error = isset($result['msg']) ? $result['msg'] : json_encode($result, JSON_UNESCAPED_UNICODE);

throw new GatewayErrorException($error, $code);
}
} catch (\Exception $e) {
Expand Down Expand Up @@ -115,8 +118,8 @@ protected function buildHeaders(Config $config)

/**
* @param PhoneNumberInterface $to
* @param MessageInterface $message
* @param Config $config
* @param MessageInterface $message
* @param Config $config
*
* @return array
*/
Expand All @@ -137,7 +140,7 @@ public function buildSendCodeParams(PhoneNumberInterface $to, MessageInterface $

/**
* @param PhoneNumberInterface $to
* @param MessageInterface $message
* @param MessageInterface $message
*
* @return array
*
Expand Down
10 changes: 5 additions & 5 deletions tests/Gateways/YunxinGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public function testSendWithSendCode()
->andReturn('mock-params');

$gateway->shouldReceive('post')
->with('https://api.netease.im/sms/sendcode.action', 'mock-params', 'mock-headers')
->with('https://api.netease.im/sms/sendcode.action', 'mock-params', 'mock-headers')
->andReturn([
'code' => 200,
'msg' => 5,
'obj' => 6379,
],[
], [
'code' => 414,
'msg' => 'checksum',
])
Expand Down Expand Up @@ -103,10 +103,10 @@ public function testSendWithVerifyCode()
->andReturn('mock-params');

$gateway->shouldReceive('post')
->with('https://api.netease.im/sms/verifycode.action', 'mock-params', 'mock-headers')
->with('https://api.netease.im/sms/verifycode.action', 'mock-params', 'mock-headers')
->andReturn([
'code' => 200,
],[
], [
'code' => 414,
'msg' => 'checksum',
])
Expand Down Expand Up @@ -188,7 +188,7 @@ public function testBuildSendCodeParams()
'template' => 'mock-template-code',
'data' => [
'code' => '123456',
'device_id' => 'mock-device-id'
'device_id' => 'mock-device-id',
],
]);

Expand Down

0 comments on commit 25140e0

Please sign in to comment.