@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function getMessage(){ |
|
59 | + public function getMessage() { |
|
60 | 60 | return $this->message->getMessage(); |
61 | 61 | } |
62 | 62 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @param array $mobiles |
65 | 65 | * @param bool $atAll |
66 | 66 | */ |
67 | - public function setAt($mobiles = [], $atAll = false){ |
|
67 | + public function setAt($mobiles = [], $atAll = false) { |
|
68 | 68 | $this->mobiles = $mobiles; |
69 | 69 | $this->atAll = $atAll; |
70 | - if ($this->message){ |
|
71 | - $this->message->sendAt($mobiles,$atAll); |
|
70 | + if ($this->message) { |
|
71 | + $this->message->sendAt($mobiles, $atAll); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * |
78 | 78 | */ |
79 | - public function setAccessToken(){ |
|
79 | + public function setAccessToken() { |
|
80 | 80 | $this->accessToken = $this->config['token']; |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function getRobotUrl(){ |
|
86 | + public function getRobotUrl() { |
|
87 | 87 | return $this->hookUrl . "?access_token={$this->accessToken}"; |
88 | 88 | } |
89 | 89 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @param $content |
93 | 93 | * @return $this |
94 | 94 | */ |
95 | - public function setTextMessage($content){ |
|
95 | + public function setTextMessage($content) { |
|
96 | 96 | $this->message = new Text($content); |
97 | - $this->message->sendAt($this->mobiles,$this->atAll); |
|
97 | + $this->message->sendAt($this->mobiles, $this->atAll); |
|
98 | 98 | return $this; |
99 | 99 | } |
100 | 100 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string $picUrl |
106 | 106 | * @return $this |
107 | 107 | */ |
108 | - public function setLinkMessage($title, $text, $messageUrl, $picUrl = ''){ |
|
109 | - $this->message = new Link($title,$text,$messageUrl,$picUrl); |
|
110 | - $this->message->sendAt($this->mobiles,$this->atAll); |
|
108 | + public function setLinkMessage($title, $text, $messageUrl, $picUrl = '') { |
|
109 | + $this->message = new Link($title, $text, $messageUrl, $picUrl); |
|
110 | + $this->message->sendAt($this->mobiles, $this->atAll); |
|
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param $text |
117 | 117 | * @return $this |
118 | 118 | */ |
119 | - public function setMarkdownMessage($title, $markdown){ |
|
120 | - $this->message = new Markdown($title,$markdown); |
|
121 | - $this->message->sendAt($this->mobiles,$this->atAll); |
|
119 | + public function setMarkdownMessage($title, $markdown) { |
|
120 | + $this->message = new Markdown($title, $markdown); |
|
121 | + $this->message->sendAt($this->mobiles, $this->atAll); |
|
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
@@ -130,26 +130,26 @@ discard block |
||
130 | 130 | * @param int $btnOrientation |
131 | 131 | * @return ActionCard|Message |
132 | 132 | */ |
133 | - public function setActionCardMessage($title, $markdown, $hideAvatar = 0, $btnOrientation = 0){ |
|
133 | + public function setActionCardMessage($title, $markdown, $hideAvatar = 0, $btnOrientation = 0) { |
|
134 | 134 | $this->message = new ActionCard($this, $title, $markdown, $hideAvatar, $btnOrientation); |
135 | - $this->message->sendAt($this->mobiles,$this->atAll); |
|
135 | + $this->message->sendAt($this->mobiles, $this->atAll); |
|
136 | 136 | return $this->message; |
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * @return FeedCard|Message |
141 | 141 | */ |
142 | - public function setFeedCardMessage(){ |
|
142 | + public function setFeedCardMessage() { |
|
143 | 143 | $this->message = new FeedCard($this); |
144 | - $this->message->sendAt($this->mobiles,$this->atAll); |
|
144 | + $this->message->sendAt($this->mobiles, $this->atAll); |
|
145 | 145 | return $this->message; |
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * @return bool|string |
150 | 150 | */ |
151 | - public function send(){ |
|
152 | - if (! $this->config['enabled']){ |
|
151 | + public function send() { |
|
152 | + if (!$this->config['enabled']) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'timeout' => $this->config['timeout'] ?? 2.0, |
158 | 158 | ]); |
159 | 159 | |
160 | - $request = $client->post($this->getRobotUrl(),[ |
|
160 | + $request = $client->post($this->getRobotUrl(), [ |
|
161 | 161 | 'body' => json_encode($this->message->getBody()), |
162 | 162 | 'headers' => [ |
163 | 163 | 'Content-Type' => 'application/json', |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string $robot |
33 | 33 | * @return $this |
34 | 34 | */ |
35 | - public function with($robot = 'default'){ |
|
35 | + public function with($robot = 'default') { |
|
36 | 36 | $this->robot = $robot; |
37 | 37 | $this->dingTalkService = new DingTalkService($this->config[$robot]); |
38 | 38 | return $this; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $content |
44 | 44 | * @return mixed |
45 | 45 | */ |
46 | - public function text($content = ''){ |
|
46 | + public function text($content = '') { |
|
47 | 47 | return $this->dingTalkService |
48 | 48 | ->setTextMessage($content) |
49 | 49 | ->send(); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param $text |
55 | 55 | * @return mixed |
56 | 56 | */ |
57 | - public function action($title, $text){ |
|
57 | + public function action($title, $text) { |
|
58 | 58 | return $this->dingTalkService |
59 | - ->setActionCardMessage($title,$text); |
|
59 | + ->setActionCardMessage($title, $text); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param bool $atAll |
65 | 65 | * @return $this |
66 | 66 | */ |
67 | - public function at($mobiles = [], $atAll = false){ |
|
67 | + public function at($mobiles = [], $atAll = false) { |
|
68 | 68 | $this->dingTalkService |
69 | - ->setAt($mobiles,$atAll); |
|
69 | + ->setAt($mobiles, $atAll); |
|
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @param string $picUrl |
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | - public function link($title, $text, $url, $picUrl = ''){ |
|
80 | + public function link($title, $text, $url, $picUrl = '') { |
|
81 | 81 | return $this->dingTalkService |
82 | - ->setLinkMessage($title,$text,$url,$picUrl) |
|
82 | + ->setLinkMessage($title, $text, $url, $picUrl) |
|
83 | 83 | ->send(); |
84 | 84 | } |
85 | 85 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * @param $markdown |
89 | 89 | * @return mixed |
90 | 90 | */ |
91 | - public function markdown($title, $markdown){ |
|
91 | + public function markdown($title, $markdown) { |
|
92 | 92 | return $this->dingTalkService |
93 | - ->setMarkdownMessage($title,$markdown) |
|
93 | + ->setMarkdownMessage($title, $markdown) |
|
94 | 94 | ->send(); |
95 | 95 | } |
96 | 96 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | * @param int $btnOrientation |
102 | 102 | * @return mixed |
103 | 103 | */ |
104 | - public function actionCard($title, $markdown, $hideAvatar = 0, $btnOrientation = 0){ |
|
104 | + public function actionCard($title, $markdown, $hideAvatar = 0, $btnOrientation = 0) { |
|
105 | 105 | return $this->dingTalkService |
106 | - ->setActionCardMessage($title,$markdown,$hideAvatar,$btnOrientation); |
|
106 | + ->setActionCardMessage($title, $markdown, $hideAvatar, $btnOrientation); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return mixed |
111 | 111 | */ |
112 | - public function feed(){ |
|
112 | + public function feed() { |
|
113 | 113 | return $this->dingTalkService |
114 | 114 | ->setFeedCardMessage(); |
115 | 115 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | protected function registerLaravelBindings() |
38 | 38 | { |
39 | - $this->app->singleton(DingTalk::class, function ($app) { |
|
39 | + $this->app->singleton(DingTalk::class, function($app) { |
|
40 | 40 | return new DingTalk($app['config']['ding']); |
41 | 41 | }); |
42 | 42 | } |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | use DingNotice\DingTalk; |
4 | 4 | |
5 | -if (!function_exists('ding')){ |
|
5 | +if (!function_exists('ding')) { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @return bool|DingTalk |
9 | 9 | */ |
10 | - function ding(){ |
|
10 | + function ding() { |
|
11 | 11 | |
12 | 12 | $arguments = func_get_args(); |
13 | 13 |
@@ -6,19 +6,19 @@ |
||
6 | 6 | |
7 | 7 | 'default' => [ |
8 | 8 | // 是否要开启机器人,关闭则不再发送消息 |
9 | - 'enabled' => env('DING_ENABLED',true), |
|
9 | + 'enabled' => env('DING_ENABLED', true), |
|
10 | 10 | // 机器人的access_token |
11 | - 'token' => env('DING_TOKEN',''), |
|
11 | + 'token' => env('DING_TOKEN', ''), |
|
12 | 12 | // 钉钉请求的超时时间 |
13 | - 'timeout' => env('DING_TIME_OUT',2.0) |
|
13 | + 'timeout' => env('DING_TIME_OUT', 2.0) |
|
14 | 14 | ], |
15 | 15 | |
16 | 16 | 'other' => [ |
17 | - 'enabled' => env('OTHER_DING_ENABLED',true), |
|
17 | + 'enabled' => env('OTHER_DING_ENABLED', true), |
|
18 | 18 | |
19 | - 'token' => env('OTHER_DING_TOKEN',''), |
|
19 | + 'token' => env('OTHER_DING_TOKEN', ''), |
|
20 | 20 | |
21 | - 'timeout' => env('OTHER_DING_TIME_OUT',2.0) |
|
21 | + 'timeout' => env('OTHER_DING_TIME_OUT', 2.0) |
|
22 | 22 | ] |
23 | 23 | |
24 | 24 | ]; |
25 | 25 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | } |
17 | 17 | |
18 | - public function setMessage(){ |
|
18 | + public function setMessage() { |
|
19 | 19 | $this->message = [ |
20 | 20 | 'feedCard' => [ |
21 | 21 | 'links' => [] |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | ]; |
25 | 25 | } |
26 | 26 | |
27 | - public function addLinks($title,$messageUrl,$picUrl){ |
|
27 | + public function addLinks($title, $messageUrl, $picUrl) { |
|
28 | 28 | $this->message['feedCard']['links'][] = [ |
29 | 29 | 'title' => $title, |
30 | 30 | 'messageURL' => $messageUrl, |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | return $this; |
34 | 34 | } |
35 | 35 | |
36 | - public function send(){ |
|
36 | + public function send() { |
|
37 | 37 | $this->service->setMessage($this); |
38 | 38 | return $this->service->send(); |
39 | 39 | } |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | |
10 | 10 | protected $service; |
11 | 11 | |
12 | - public function __construct(DingTalkService $service,$title, $markdown, $hideAvatar = 0, $btnOrientation = 0) |
|
12 | + public function __construct(DingTalkService $service, $title, $markdown, $hideAvatar = 0, $btnOrientation = 0) |
|
13 | 13 | { |
14 | 14 | $this->service = $service; |
15 | - $this->setMessage($title,$markdown,$hideAvatar,$btnOrientation); |
|
15 | + $this->setMessage($title, $markdown, $hideAvatar, $btnOrientation); |
|
16 | 16 | } |
17 | 17 | |
18 | - public function setMessage($title, $markdown, $hideAvatar = 0, $btnOrientation = 0){ |
|
18 | + public function setMessage($title, $markdown, $hideAvatar = 0, $btnOrientation = 0) { |
|
19 | 19 | $this->message = [ |
20 | 20 | 'msgtype' => 'actionCard', |
21 | 21 | 'actionCard' => [ |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | ]; |
28 | 28 | } |
29 | 29 | |
30 | - public function single($title,$url){ |
|
30 | + public function single($title, $url) { |
|
31 | 31 | $this->message['actionCard']['singleTitle'] = $title; |
32 | 32 | $this->message['actionCard']['singleURL'] = $url; |
33 | 33 | $this->service->setMessage($this); |
34 | 34 | return $this; |
35 | 35 | } |
36 | 36 | |
37 | - public function addButtons($title,$url){ |
|
37 | + public function addButtons($title, $url) { |
|
38 | 38 | $this->message['actionCard']['btns'][] = [ |
39 | 39 | 'title' => $title, |
40 | 40 | 'actionURL' => $url |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
45 | - public function send(){ |
|
45 | + public function send() { |
|
46 | 46 | $this->service->setMessage($this); |
47 | 47 | return $this->service->send(); |
48 | 48 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | class Link extends Message |
6 | 6 | { |
7 | 7 | |
8 | - public function __construct($title,$text,$messageUrl,$picUrl = '') |
|
8 | + public function __construct($title, $text, $messageUrl, $picUrl = '') |
|
9 | 9 | { |
10 | - $this->setMessage($title,$text,$messageUrl,$picUrl); |
|
10 | + $this->setMessage($title, $text, $messageUrl, $picUrl); |
|
11 | 11 | } |
12 | 12 | |
13 | - public function setMessage($title,$text,$messageUrl,$picUrl = ''){ |
|
14 | - $this->message = [ |
|
13 | + public function setMessage($title, $text, $messageUrl, $picUrl = '') { |
|
14 | + $this->message = [ |
|
15 | 15 | 'msgtype' => 'link', |
16 | 16 | 'link' => [ |
17 | 17 | 'text' => $text, |
@@ -4,13 +4,13 @@ |
||
4 | 4 | |
5 | 5 | class Markdown extends Message |
6 | 6 | { |
7 | - public function __construct($title,$markdown) |
|
7 | + public function __construct($title, $markdown) |
|
8 | 8 | { |
9 | - $this->setMessage($title,$markdown); |
|
9 | + $this->setMessage($title, $markdown); |
|
10 | 10 | } |
11 | 11 | |
12 | - public function setMessage($title,$markdown){ |
|
13 | - $this->message = [ |
|
12 | + public function setMessage($title, $markdown) { |
|
13 | + $this->message = [ |
|
14 | 14 | 'msgtype' => 'markdown', |
15 | 15 | 'markdown' => [ |
16 | 16 | 'title' => $title, |