Skip to content

Commit 8d6641b

Browse files
calchenStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent c807730 commit 8d6641b

16 files changed

+107
-113
lines changed

config/dingtalk_robot.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
'access_token' => env('DINGTALK_ROBOT_ACCESS_TOKEN', ''),
88

99
// 请求的超时时间
10-
'timeout' => env('DINGTALK_ROBOT_TIMEOUT', 2.0)
11-
]
12-
];
10+
'timeout' => env('DINGTALK_ROBOT_TIMEOUT', 2.0),
11+
],
12+
];

src/DingtalkRobot.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@
55
use Calchen\LaravelDingtalkRobot\Exception\Exception;
66
use Calchen\LaravelDingtalkRobot\Exception\HttpException;
77
use Calchen\LaravelDingtalkRobot\Exception\InvalidConfigurationException;
8-
use GuzzleHttp\Client;
98
use Calchen\LaravelDingtalkRobot\Message\Message;
9+
use GuzzleHttp\Client;
1010

1111
/**
12-
* 钉钉群消息机器 API
12+
* 钉钉群消息机器 API.
1313
*
1414
* Class DingtalkRobot
15-
* @package Calchen\LaravelDingtalkRobot
1615
*/
1716
class DingtalkRobot
1817
{
1918
protected $config;
2019
/**
2120
* @var string
2221
*/
23-
protected $accessToken = "";
22+
protected $accessToken = '';
2423
/**
2524
* @var string
2625
*/
27-
protected $robotUrl = "https://oapi.dingtalk.com/robot/send";
26+
protected $robotUrl = 'https://oapi.dingtalk.com/robot/send';
2827

2928
/**
3029
* 消息对象
@@ -42,12 +41,13 @@ public function __construct()
4241
}
4342

4443
/**
45-
* 指定机器人名称,默认为 default
44+
* 指定机器人名称,默认为 default.
4645
*
4746
* @param string $name
4847
*
49-
* @return $this
5048
* @throws \Exception
49+
*
50+
* @return $this
5151
*/
5252
public function robot($name = 'default'): self
5353
{
@@ -68,18 +68,20 @@ public function robot($name = 'default'): self
6868
*
6969
* @param Message $message
7070
*
71-
* @return $this
7271
* @throws \Exception
72+
*
73+
* @return $this
7374
*/
7475
public function setMessage(Message $message): self
7576
{
7677
$this->message = $message;
7778
$this->robot($message->getRobot());
79+
7880
return $this;
7981
}
8082

8183
/**
82-
* 获取 message 对象的内容
84+
* 获取 message 对象的内容.
8385
*
8486
* @return array
8587
*/
@@ -89,7 +91,7 @@ public function getMessage(): array
8991
}
9092

9193
/**
92-
* 获取附带 access_token 的 webhook Url
94+
* 获取附带 access_token 的 webhook Url.
9395
*
9496
* @return string
9597
*/
@@ -99,10 +101,11 @@ protected function getRobotUrl(): string
99101
}
100102

101103
/**
102-
* 发起请求,返回的内容与直接调用钉钉接口返回的内容一致
104+
* 发起请求,返回的内容与直接调用钉钉接口返回的内容一致.
103105
*
104-
* @return bool|string
105106
* @throws Exception
107+
*
108+
* @return bool|string
106109
*/
107110
public function send(): string
108111
{
@@ -118,15 +121,16 @@ public function send(): string
118121
$response = $client->post(
119122
$this->getRobotUrl(),
120123
[
121-
'json' => $this->message->getMessage(),
124+
'json' => $this->message->getMessage(),
122125
'headers' => [
123126
'Content-Type' => 'application/json',
124-
]
127+
],
125128
]
126129
);
130+
127131
return $response->getBody()->getContents();
128132
} catch (Exception $e) {
129133
throw new HttpException($e->getMessage(), $e->getCode(), $e);
130134
}
131135
}
132-
}
136+
}

src/DingtalkRobotChannel.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
use Illuminate\Notifications\Notification;
77

88
/**
9-
* 自定义的钉钉群机器人消息发送渠道
9+
* 自定义的钉钉群机器人消息发送渠道.
1010
*
1111
* Class DingtalkRobotChannel
12-
* @package Calchen\LaravelDingtalkRobot
1312
*/
1413
class DingtalkRobotChannel
1514
{
@@ -32,4 +31,4 @@ public function send($notifiable, Notification $notification)
3231
$ding = new DingtalkRobot();
3332
$ding->setMessage($message)->send();
3433
}
35-
}
34+
}

src/DingtalkRobotNoticeServiceProvider.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Laravel\Lumen\Application as LumenApplication;
88

99
/**
10-
* DingNotice SDK 的 ServiceProvider 只支持 Laravel
10+
* DingNotice SDK 的 ServiceProvider 只支持 Laravel.
1111
*/
1212
class DingtalkRobotNoticeServiceProvider extends ServiceProvider
1313
{
@@ -22,20 +22,19 @@ public function boot()
2222
}
2323

2424
/**
25-
* 处理配置项
25+
* 处理配置项.
2626
*
2727
* @return void
2828
*/
2929
protected function setupConfig(): void
3030
{
31-
$source = realpath($raw = __DIR__ . '/../config/dingtalk_robot.php') ?: $raw;
31+
$source = realpath($raw = __DIR__.'/../config/dingtalk_robot.php') ?: $raw;
3232

3333
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
3434
$this->publishes([
35-
$source => config_path('dingtalk_robot.php')
35+
$source => config_path('dingtalk_robot.php'),
3636
]);
37-
}
38-
elseif ($this->app instanceof LumenApplication) {
37+
} elseif ($this->app instanceof LumenApplication) {
3938
$this->app->configure('dingtalk_robot');
4039
}
4140

src/Exceptions/Exception.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
namespace Calchen\LaravelDingtalkRobot\Exception;
44

55
/**
6-
* 异常基类
6+
* 异常基类.
77
*
88
* Class Exception
9-
* @package Calchen\LaravelDingtalkRobot\Exception
109
*/
1110
class Exception extends \Exception
1211
{
1312
//
14-
}
13+
}

src/Exceptions/HttpException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
namespace Calchen\LaravelDingtalkRobot\Exception;
44

55
/**
6-
* Http 请求异常
6+
* Http 请求异常.
77
*
88
* Class HttpException
9-
* @package Calchen\LaravelDingtalkRobot\Exception
109
*/
1110
class HttpException extends Exception
1211
{
1312
//
14-
}
13+
}

src/Exceptions/InvalidArgumentException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
namespace Calchen\LaravelDingtalkRobot\Exception;
44

55
/**
6-
* 入参异常
6+
* 入参异常.
77
*
88
* Class InvalidArgumentException
9-
* @package Calchen\LaravelDingtalkRobot\Exception
109
*/
1110
class InvalidArgumentException extends Exception
1211
{
1312
//
14-
}
13+
}

src/Exceptions/InvalidConfigurationException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
namespace Calchen\LaravelDingtalkRobot\Exception;
44

55
/**
6-
* 配置文件异常
6+
* 配置文件异常.
77
*
88
* Class InvalidConfigurationException
9-
* @package Calchen\LaravelDingtalkRobot\Exception
109
*/
1110
class InvalidConfigurationException extends Exception
1211
{
1312
//
14-
}
13+
}

src/Message/ActionCardMessage.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
use Calchen\LaravelDingtalkRobot\Exception\InvalidConfigurationException;
66

77
/**
8-
* ActionCard类型,包含整体跳转和独立跳转
8+
* ActionCard类型,包含整体跳转和独立跳转.
99
*
1010
* Class DingtalkActionCardMessage
11-
* @package Calchen\LaravelDingtalkRobot
1211
*/
1312
class ActionCardMessage extends Message
1413
{
@@ -32,19 +31,19 @@ public function __construct(string $title, string $text, int $hideAvatar = 0, in
3231
*/
3332
const HIDE_AVATAR_VALUES = [
3433
0, // 按钮竖直排列
35-
1 // 按钮横向排列
34+
1, // 按钮横向排列
3635
];
3736

3837
/**
3938
* btnOrientation 的值
4039
*/
4140
const BTN_ORIENTATION_VALUES = [
4241
0, // 正常发消息者头像
43-
1 // 隐藏发消息者头像
42+
1, // 隐藏发消息者头像
4443
];
4544

4645
/**
47-
* ActionCard 的整体跳转和独立跳转两种类型中 title text hideAvatar btnOrientation 都是共同拥有的
46+
* ActionCard 的整体跳转和独立跳转两种类型中 title text hideAvatar btnOrientation 都是共同拥有的.
4847
*
4948
* @param string $title 首屏会话透出的展示内容
5049
* @param string $text markdown 格式的消息
@@ -56,25 +55,25 @@ public function __construct(string $title, string $text, int $hideAvatar = 0, in
5655
public function setMessage(string $title, string $text, int $hideAvatar = 0, int $btnOrientation = 0): void
5756
{
5857
if (array_search($hideAvatar, self::HIDE_AVATAR_VALUES) === false) {
59-
throw new InvalidConfigurationException("hideAvatar value can only be 0 or 1");
58+
throw new InvalidConfigurationException('hideAvatar value can only be 0 or 1');
6059
}
6160
if (array_search($btnOrientation, self::BTN_ORIENTATION_VALUES) === false) {
62-
throw new InvalidConfigurationException("btnOrientation value can only be 0 or 1");
61+
throw new InvalidConfigurationException('btnOrientation value can only be 0 or 1');
6362
}
6463

6564
$this->message = [
66-
'msgtype' => 'actionCard',
65+
'msgtype' => 'actionCard',
6766
'actionCard' => [
68-
'title' => $title,
69-
'text' => $text,
70-
'hideAvatar' => $hideAvatar,
71-
'btnOrientation' => $btnOrientation
72-
]
67+
'title' => $title,
68+
'text' => $text,
69+
'hideAvatar' => $hideAvatar,
70+
'btnOrientation' => $btnOrientation,
71+
],
7372
];
7473
}
7574

7675
/**
77-
* 设置整体跳转类型参数
76+
* 设置整体跳转类型参数.
7877
*
7978
* @param string $singleTitle 单个按钮的方案。(设置此项和singleURL后btns无效。)
8079
* @param string $singleUrl 点击singleTitle按钮触发的URL
@@ -85,11 +84,12 @@ public function setSingle(string $singleTitle, string $singleUrl): self
8584
{
8685
$this->message['actionCard']['singleTitle'] = $singleTitle;
8786
$this->message['actionCard']['singleURL'] = $singleUrl;
87+
8888
return $this;
8989
}
9090

9191
/**
92-
* 设置独立跳转类型按钮参数
92+
* 设置独立跳转类型按钮参数.
9393
*
9494
* @param string $title 按钮方案
9595
* @param string $actionUrl 点击按钮触发的URL
@@ -99,9 +99,10 @@ public function setSingle(string $singleTitle, string $singleUrl): self
9999
public function addButton(string $title, string $actionUrl): self
100100
{
101101
$this->message['actionCard']['btns'][] = [
102-
'title' => $title,
103-
'actionURL' => $actionUrl
102+
'title' => $title,
103+
'actionURL' => $actionUrl,
104104
];
105+
105106
return $this;
106107
}
107-
}
108+
}

src/Message/FeedCardMessage.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,20 @@ class FeedCardMessage extends Message
1010
public function __construct()
1111
{
1212
$this->setMessage();
13-
1413
}
1514

16-
/**
17-
*
18-
*/
1915
public function setMessage(): void
2016
{
2117
$this->message = [
2218
'feedCard' => [
23-
'links' => []
19+
'links' => [],
2420
],
25-
'msgtype' => 'feedCard'
21+
'msgtype' => 'feedCard',
2622
];
2723
}
2824

2925
/**
30-
* 增加链接
26+
* 增加链接.
3127
*
3228
* @param string $title 单条信息文本
3329
* @param string $messageUrl 点击单条信息到跳转链接
@@ -38,10 +34,11 @@ public function setMessage(): void
3834
public function addLink(string $title, string $messageUrl, string $picUrl): self
3935
{
4036
$this->message['feedCard']['links'][] = [
41-
'title' => $title,
37+
'title' => $title,
4238
'messageURL' => $messageUrl,
43-
'picURL' => $picUrl
39+
'picURL' => $picUrl,
4440
];
41+
4542
return $this;
4643
}
47-
}
44+
}

0 commit comments

Comments
 (0)