Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ composer.lock
.subsplit
.php_cs.cache
.php-cs-fixer.cache
.pint.cache
.idea
/index.php
/config.php
Expand Down
12 changes: 0 additions & 12 deletions .php-cs-fixer.dist.php

This file was deleted.

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"phpunit/phpunit": "^9.5.8",
"mockery/mockery": "^1.4.2",
"jetbrains/phpstorm-attributes": "^1.0",
"friendsofphp/php-cs-fixer": "^3.54"
"laravel/pint": "^1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -33,8 +33,9 @@
],
"scripts": {
"phpstan": "phpstan analyse",
"check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php-cs-fixer.dist.php --dry-run --allow-risky=yes --ansi",
"fix-style": "php-cs-fixer fix --using-cache=no --config=.php-cs-fixer.dist.php --allow-risky=yes --ansi",
"check-style": "pint --test",
"fix-style": "pint",
"fix": "pint",
"test": "phpunit --colors",
"psalm": "psalm --show-info=true --no-cache",
"psalm-fix": "psalm --no-cache --alter --issues=MissingReturnType,MissingParamType"
Expand Down
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "symfony"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot laravel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Laravel preset in commit 8adf754. All 95 files reformatted with Laravel coding standards.

}
8 changes: 4 additions & 4 deletions src/EasySms.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function strategy(?string $strategy = null): StrategyInterface
}

if (!\class_exists($strategy)) {
$strategy = __NAMESPACE__ . '\Strategies\\' . \ucfirst($strategy);
$strategy = __NAMESPACE__.'\Strategies\\'.\ucfirst($strategy);
}

if (!\class_exists($strategy)) {
Expand Down Expand Up @@ -183,7 +183,7 @@ protected function formatGatewayClassName(string $name): string

$name = \ucfirst(\str_replace(['-', '_', ''], '', $name));

return __NAMESPACE__ . "\\Gateways\\{$name}Gateway";
return __NAMESPACE__."\\Gateways\\{$name}Gateway";
}

/**
Expand All @@ -208,7 +208,7 @@ protected function formatMessage(MessageInterface|array|string $message): Messag
if (!($message instanceof MessageInterface)) {
if (!\is_array($message)) {
$message = [
'content' => $message,
'content' => $message,
'template' => $message,
];
}
Expand Down Expand Up @@ -248,4 +248,4 @@ protected function formatGateways(array $gateways): array

return $result;
}
}
}
20 changes: 10 additions & 10 deletions src/Gateways/WeiqucloudGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Overtrue\EasySms\Gateways;

use Overtrue\EasySms\Exceptions\GatewayErrorException;
use Overtrue\EasySms\Contracts\MessageInterface;
use Overtrue\EasySms\Contracts\PhoneNumberInterface;
use Overtrue\EasySms\Exceptions\GatewayErrorException;
use Overtrue\EasySms\Support\Config;
use Overtrue\EasySms\Traits\HasHttpRequest;

/**
* 微趣云短信网关
* 微趣云短信网关.
*/
class WeiqucloudGateway extends Gateway
{
Expand All @@ -20,17 +20,17 @@ class WeiqucloudGateway extends Gateway
public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config)
{
$data = [
"userId" => $config->get('userId'),
"account" => $config->get('account'),
"password" => $config->get('password'),
"mobile" => $to->getNumber(),
"content" => $message->getContent($this),
"sendTime" => "",
"action" => "sendhy",
'userId' => $config->get('userId'),
'account' => $config->get('account'),
'password' => $config->get('password'),
'mobile' => $to->getNumber(),
'content' => $message->getContent($this),
'sendTime' => '',
'action' => 'sendhy',
];
$result = $this->postJson(self::ENDPOINT_URL, $data);

if ($result['code'] === 200 && $result['data']['status'] === 'Success') {
if (200 === $result['code'] && 'Success' === $result['data']['status']) {
return $result;
}
throw new GatewayErrorException("短信发送失败: {$result['data']['message']}, remainPoint: {$result['data']['remainPoint']}, taskID:{$result['data']['taskID']}", 500, $result);
Expand Down
11 changes: 5 additions & 6 deletions tests/Gateways/WeiqucloudGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ public function testSend()
'action' => 'sendhy',
];


// 成功响应的数据结构
$successResponse = [
'code' => 200,
'data' => [
'status' => 'Success',
'taskID' => 'mock-task-id',
'remainPoint' => 100,
'message' => '发送成功'
]
'message' => '发送成功',
],
];

// 失败响应的数据结构
Expand All @@ -58,8 +57,8 @@ public function testSend()
'status' => 'Failed',
'message' => '账户余额不足',
'remainPoint' => 0,
'taskID' => 'mock-task-id-failed'
]
'taskID' => 'mock-task-id-failed',
],
];

$gateway->shouldReceive('postJson')
Expand All @@ -81,4 +80,4 @@ public function testSend()

$gateway->send(new PhoneNumber(18188888888), $message, $config);
}
}
}
Loading