Skip to content

Commit

Permalink
Merge pull request #6 from asundust/analysis-lZgAnO
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
asundust authored Feb 11, 2023
2 parents 013f450 + 9b274b0 commit 6a25af4
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 55 deletions.
2 changes: 0 additions & 2 deletions src/Http/Actions/SendTestMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class SendTestMessage extends RowAction
public $name = '发送测试消息';

/**
* @param WechatWorkPushUserModel $user
* @return \Encore\Admin\Actions\Response
* @throws \EasyWeChat\Kernel\Exceptions\BadResponseException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
Expand Down
8 changes: 0 additions & 8 deletions src/Http/Controllers/WechatWorkPushConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

class WechatWorkPushConfigController extends Controller
{
/**
* @param Content $content
* @return Content
*/
public function index(Content $content): Content
{
return $content
Expand All @@ -34,10 +30,6 @@ public function index(Content $content): Content
});
}

/**
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(Request $request): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse|\Illuminate\Contracts\Foundation\Application
{
$data = [
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Controllers/WechatWorkPushHandleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class WechatWorkPushHandleController extends Controller

/**
* @param $secret
* @param Request $request
* @return array
*
* @throws \EasyWeChat\Kernel\Exceptions\BadResponseException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
Expand Down
4 changes: 0 additions & 4 deletions src/Http/Controllers/WechatWorkPushUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class WechatWorkPushUserController extends AdminController

/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid(): Grid
{
Expand Down Expand Up @@ -100,8 +98,6 @@ protected function grid(): Grid

/**
* Make a form builder.
*
* @return Form
*/
protected function form(): Form
{
Expand Down
25 changes: 12 additions & 13 deletions src/Http/Traits/WechatWorkPushSendMessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ 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 链接标题
* @return array
*
* @throws InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\BadResponseException
Expand All @@ -34,10 +33,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>';
}
$app = new Application($config);
$api = $app->getClient();
Expand All @@ -47,7 +46,7 @@ public function send(array $config, string $name, string $title, ?string $conten
'agentid' => $config['agent_id'],
'text' => [
'content' => $message,
]
],
])
->toArray();
if (0 == $result['errcode'] && 'ok' == $result['errmsg']) {
Expand All @@ -60,10 +59,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 InvalidArgumentException
Expand Down
15 changes: 7 additions & 8 deletions src/Models/WechatWorkPushConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

namespace Asundust\WechatWorkPush\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
* Asundust\WechatWorkPush\Models\WechatWorkPushConfig
* Asundust\WechatWorkPush\Models\WechatWorkPushConfig.
*
* @property int $id
* @property string|null $corp_id 企业ID
* @property string|null $agent_id 应用ID/agent_id
* @property string|null $secret 应用Secret
* @property int $id
* @property string|null $corp_id 企业ID
* @property string|null $agent_id 应用ID/agent_id
* @property string|null $secret 应用Secret
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read bool $is_complete
* @property bool $is_complete
*
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushConfig newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushConfig newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushConfig query()
Expand Down
31 changes: 14 additions & 17 deletions src/Models/WechatWorkPushUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@

namespace Asundust\WechatWorkPush\Models;

use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
* Asundust\WechatWorkPush\Models\WechatWorkPushUser
* Asundust\WechatWorkPush\Models\WechatWorkPushUser.
*
* @property int $id
* @property string $name 用户的账户
* @property string $sc_secret 用户的推送密钥
* @property int $status 状态(0禁用1启用)
* @property string|null $corp_id 用户自定企业ID
* @property string|null $agent_id 用户自定应用ID/agent_id
* @property string|null $secret 用户自定应用Secret
* @property int $id
* @property string $name 用户的账户
* @property string $sc_secret 用户的推送密钥
* @property int $status 状态(0禁用1启用)
* @property string|null $corp_id 用户自定企业ID
* @property string|null $agent_id 用户自定应用ID/agent_id
* @property string|null $secret 用户自定应用Secret
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read string $api_address
* @property-read string $api_address_show
* @property-read bool $is_own_wechat_work
* @property string $api_address
* @property string $api_address_show
* @property bool $is_own_wechat_work
*
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Asundust\WechatWorkPush\Models\WechatWorkPushUser query()
Expand All @@ -47,8 +46,6 @@ class WechatWorkPushUser extends Model

/**
* Settings constructor.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
Expand All @@ -68,12 +65,12 @@ public function getIsOwnWechatWorkAttribute(): bool
// api_address_show
public function getApiAddressShowAttribute(): string
{
return config('app.url') . '/push/***';
return config('app.url').'/push/***';
}

// api_address
public function getApiAddressAttribute(): string
{
return config('app.url') . '/push/' . $this->sc_secret . '?title=我是标题&content=我是内容(可不填)&url=我是链接(可不填)&url_title=链接标题(可不填)';
return config('app.url').'/push/'.$this->sc_secret.'?title=我是标题&content=我是内容(可不填)&url=我是链接(可不填)&url_title=链接标题(可不填)';
}
}
1 change: 1 addition & 0 deletions src/WechatWorkPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class WechatWorkPush extends Extension

/**
* {@inheritdoc}
*
* @throws \Exception
*/
public static function import()
Expand Down
1 change: 0 additions & 1 deletion src/WechatWorkPushServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class WechatWorkPushServiceProvider extends ServiceProvider
{
/**
* @param WechatWorkPush $extension
* @return void
*/
public function boot(WechatWorkPush $extension)
Expand Down

0 comments on commit 6a25af4

Please sign in to comment.