Skip to content

Commit 2d11b9e

Browse files
committed
调整 connection 为 robot
1 parent 2eb6a38 commit 2d11b9e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/DingtalkRobot.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DingtalkRobot
3838
*/
3939
public function __construct()
4040
{
41-
$this->connection();
41+
$this->robot();
4242
}
4343

4444
/**
@@ -49,12 +49,12 @@ public function __construct()
4949
* @return $this
5050
* @throws \Exception
5151
*/
52-
public function connection($name = 'default'): self
52+
public function robot($name = 'default'): self
5353
{
5454
$configs = config('dingtalk_robot');
5555

5656
if (!isset($configs[$name])) {
57-
throw new InvalidConfigurationException("Connection name: {$name} not exist. Please check your setting in dingtalk_robot.php");
57+
throw new InvalidConfigurationException("Robot name: {$name} not exist. Please check your setting in dingtalk_robot.php");
5858
}
5959

6060
$this->config = $configs[$name];
@@ -74,7 +74,7 @@ public function connection($name = 'default'): self
7474
public function setMessage(Message $message): self
7575
{
7676
$this->message = $message;
77-
$this->connection($message->getConnection());
77+
$this->robot($message->getRobot());
7878
return $this;
7979
}
8080

src/Message/Message.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class Message
1717
protected $at = [];
1818

1919
// 设置机器人名称,默认为 default
20-
protected $connection = 'default';
20+
protected $robot = 'default';
2121

2222

2323
/**
@@ -33,13 +33,13 @@ public function getMessage(): array
3333
/**
3434
* 设置接受消息的机器人名称
3535
*
36-
* @param $connection
36+
* @param $robot
3737
*
3838
* @return Message
3939
*/
40-
public function setConnection($connection): self
40+
public function setRobot($robot): self
4141
{
42-
$this->connection = $connection;
42+
$this->robot = $robot;
4343
return $this;
4444
}
4545

@@ -48,8 +48,8 @@ public function setConnection($connection): self
4848
*
4949
* @return string
5050
*/
51-
public function getConnection(): string
51+
public function getRobot(): string
5252
{
53-
return $this->connection;
53+
return $this->robot;
5454
}
5555
}

src/helpers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
* 获取钉钉群机器人接口
88
*
99
* @return DingtalkRobot
10+
* @throws Exception
1011
*/
1112
function dingtalk_robot()
1213
{
1314
$arguments = func_get_args();
1415

16+
/** @var DingtalkRobot $dingTalk */
1517
$dingTalk = app(DingtalkRobot::class);
1618

1719
if (empty($arguments)) {
1820
return $dingTalk;
1921
}
2022

21-
return $dingTalk->connection($arguments[0]);
23+
return $dingTalk->robot($arguments[0]);
2224
}
2325
}

0 commit comments

Comments
 (0)