Skip to content

Commit

Permalink
Merge pull request #5 from asundust/analysis-QMv556
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
asundust authored Jul 4, 2021
2 parents 79f8440 + 37840f0 commit f7eea90
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/Http/Actions/SendTestMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function handle(WechatWorkPushUserModel $user)
$type = '默认';
}

$title = '当前使用的【' . $type . '配置】企业微信通道发送的测试消息';
$title = '当前使用的【'.$type.'配置】企业微信通道发送的测试消息';
$result = $this->send($config, $user->name, $title);
if (0 == $result['code']) {
return $this->response()->success('使用【' . $type . '配置】企业微信通道发送消息成功');
return $this->response()->success('使用【'.$type.'配置】企业微信通道发送消息成功');
}

return $this->response()->success('使用【' . $type . '配置】企业微信通道发送消息失败:' . $result['message']);
return $this->response()->success('使用【'.$type.'配置】企业微信通道发送消息失败:'.$result['message']);
}
}
25 changes: 12 additions & 13 deletions src/Http/Traits/SendMessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
use EasyWeChat\Factory;

/**
* Trait SendMessageTrait
* Trait SendMessageTrait.
*
* @package Asundust\WechatWorkPush\Http\Traits
* @deprecated 弃用 请使用WechatWorkPushSendMessageTrait 将在1.1.0版本移除
*/
trait SendMessageTrait
{
/**
* 使用自定配置发送消息.
*
* @param array $config 配置 ['corp_id' => 'xxx', 'agent_id' => 'xxx', 'secret' => 'xxx'];
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param array $config 配置 ['corp_id' => 'xxx', 'agent_id' => 'xxx', 'secret' => 'xxx'];
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string|null $urlTitle 链接标题
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
Expand All @@ -30,10 +29,10 @@ public function send(array $config, string $name, string $title, ?string $conten
{
$message = $title;
if ($content) {
$message .= "\n\n" . $content;
$message .= "\n\n".$content;
}
if ($url) {
$message .= "\n\n" . '<a href="' . $url . '">' . ($urlTitle ?: $url) . '</a>';
$message .= "\n\n".'<a href="'.$url.'">'.($urlTitle ?: $url).'</a>';
}
$messenger = Factory::work($config)->messenger;
$result = $messenger->ofAgent($config['agent_id'])->message($message)->toUser($name ?? '@all')->send();
Expand All @@ -47,10 +46,10 @@ public function send(array $config, string $name, string $title, ?string $conten
/**
* 使用默认配置发送消息.
*
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string|null $urlTitle 链接标题
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
Expand Down
26 changes: 12 additions & 14 deletions src/Http/Traits/WechatWorkPushSendMessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
use EasyWeChat\Factory;

/**
* Trait WechatWorkPushSendMessageTrait
*
* @package Asundust\WechatWorkPush\Http\Traits
* Trait WechatWorkPushSendMessageTrait.
*/
trait WechatWorkPushSendMessageTrait
{
/**
* 使用自定配置发送消息.
*
* @param array $config 配置 ['corp_id' => 'xxx', 'agent_id' => 'xxx', 'secret' => 'xxx'];
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param array $config 配置 ['corp_id' => 'xxx', 'agent_id' => 'xxx', 'secret' => 'xxx'];
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string|null $urlTitle 链接标题
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
Expand All @@ -29,10 +27,10 @@ public function send(array $config, string $name, string $title, ?string $conten
{
$message = $title;
if ($content) {
$message .= "\n\n" . $content;
$message .= "\n\n".$content;
}
if ($url) {
$message .= "\n\n" . '<a href="' . $url . '">' . ($urlTitle ?: $url) . '</a>';
$message .= "\n\n".'<a href="'.$url.'">'.($urlTitle ?: $url).'</a>';
}
$messenger = Factory::work($config)->messenger;
$result = $messenger->ofAgent($config['agent_id'])->message($message)->toUser($name ?? '@all')->send();
Expand All @@ -46,10 +44,10 @@ public function send(array $config, string $name, string $title, ?string $conten
/**
* 使用默认配置发送消息.
*
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string $name 用户
* @param string $title 标题
* @param string|null $content 内容
* @param string|null $url 链接
* @param string|null $urlTitle 链接标题
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
Expand Down

0 comments on commit f7eea90

Please sign in to comment.