作者 竞泽

style:format

@@ -4,7 +4,7 @@ use Lackoxygen\ExceptionPush\Agents\{Ding, Wx}; @@ -4,7 +4,7 @@ use Lackoxygen\ExceptionPush\Agents\{Ding, Wx};
4 4
5 return [ 5 return [
6 'agents' => [ 6 'agents' => [
7 - Wx::class => [ 7 + Wx::class => [
8 'key' => '', 'enable' => false 8 'key' => '', 'enable' => false
9 ], Ding::class => [ 9 ], Ding::class => [
10 'token' => '', 'secret' => '', 'enable' => false 10 'token' => '', 'secret' => '', 'enable' => false
@@ -22,7 +22,7 @@ class Ding implements AgentInterface @@ -22,7 +22,7 @@ class Ding implements AgentInterface
22 $talk->setTextMessage(join("\n", $content))->send(); 22 $talk->setTextMessage(join("\n", $content))->send();
23 } 23 }
24 24
25 - public function dsiabled(): bool 25 + public function disabled(): bool
26 { 26 {
27 return !$this->enable; 27 return !$this->enable;
28 } 28 }
@@ -23,11 +23,11 @@ class Wx implements AgentInterface @@ -23,11 +23,11 @@ class Wx implements AgentInterface
23 $client = Client::new('https://qyapi.weixin.qq.com'); 23 $client = Client::new('https://qyapi.weixin.qq.com');
24 24
25 $client->post('cgi-bin/webhook/send', [ 25 $client->post('cgi-bin/webhook/send', [
26 - RequestOptions::HEADERS => [ 26 + RequestOptions::HEADERS => [
27 'content-type' => 'application/json' 27 'content-type' => 'application/json'
28 ], RequestOptions::QUERY => [ 28 ], RequestOptions::QUERY => [
29 'key' => $this->key, 29 'key' => $this->key,
30 - ], RequestOptions::JSON => [ 30 + ], RequestOptions::JSON => [
31 'msgtype' => 'text', 'text' => [ 31 'msgtype' => 'text', 'text' => [
32 'content' => join("\n", $content) 32 'content' => join("\n", $content)
33 ] 33 ]
@@ -35,7 +35,7 @@ class Wx implements AgentInterface @@ -35,7 +35,7 @@ class Wx implements AgentInterface
35 ]); 35 ]);
36 } 36 }
37 37
38 - public function dsiabled(): bool 38 + public function disabled(): bool
39 { 39 {
40 return !$this->enable; 40 return !$this->enable;
41 } 41 }
@@ -37,7 +37,7 @@ class Context @@ -37,7 +37,7 @@ class Context
37 } 37 }
38 38
39 /** 39 /**
40 - * @param string $exception 40 + * @param string $exception
41 */ 41 */
42 public function setException(string $exception): void 42 public function setException(string $exception): void
43 { 43 {
@@ -53,7 +53,7 @@ class Context @@ -53,7 +53,7 @@ class Context
53 } 53 }
54 54
55 /** 55 /**
56 - * @param string $message 56 + * @param string $message
57 */ 57 */
58 public function setMessage(string $message): void 58 public function setMessage(string $message): void
59 { 59 {
@@ -69,7 +69,7 @@ class Context @@ -69,7 +69,7 @@ class Context
69 } 69 }
70 70
71 /** 71 /**
72 - * @param string $code 72 + * @param string $code
73 */ 73 */
74 public function setCode(string $code): void 74 public function setCode(string $code): void
75 { 75 {
@@ -85,7 +85,7 @@ class Context @@ -85,7 +85,7 @@ class Context
85 } 85 }
86 86
87 /** 87 /**
88 - * @param string $line 88 + * @param string $line
89 */ 89 */
90 public function setLine(string $line): void 90 public function setLine(string $line): void
91 { 91 {
@@ -101,7 +101,7 @@ class Context @@ -101,7 +101,7 @@ class Context
101 } 101 }
102 102
103 /** 103 /**
104 - * @param string $file 104 + * @param string $file
105 */ 105 */
106 public function setFile(string $file): void 106 public function setFile(string $file): void
107 { 107 {
@@ -117,7 +117,7 @@ class Context @@ -117,7 +117,7 @@ class Context
117 } 117 }
118 118
119 /** 119 /**
120 - * @param array $trace 120 + * @param array $trace
121 */ 121 */
122 public function setTrace(array $trace): void 122 public function setTrace(array $trace): void
123 { 123 {
@@ -133,7 +133,7 @@ class Context @@ -133,7 +133,7 @@ class Context
133 } 133 }
134 134
135 /** 135 /**
136 - * @param string $path 136 + * @param string $path
137 */ 137 */
138 public function setPath(string $path): void 138 public function setPath(string $path): void
139 { 139 {
@@ -149,7 +149,7 @@ class Context @@ -149,7 +149,7 @@ class Context
149 } 149 }
150 150
151 /** 151 /**
152 - * @param string $method 152 + * @param string $method
153 */ 153 */
154 public function setMethod(string $method): void 154 public function setMethod(string $method): void
155 { 155 {
@@ -165,7 +165,7 @@ class Context @@ -165,7 +165,7 @@ class Context
165 } 165 }
166 166
167 /** 167 /**
168 - * @param AgentInterface $agent 168 + * @param AgentInterface $agent
169 */ 169 */
170 public function pushAgent(AgentInterface $agent): void 170 public function pushAgent(AgentInterface $agent): void
171 { 171 {
@@ -173,7 +173,7 @@ class Context @@ -173,7 +173,7 @@ class Context
173 } 173 }
174 174
175 /** 175 /**
176 - * @param string $ip 176 + * @param string $ip
177 */ 177 */
178 public function setIp(string $ip): void 178 public function setIp(string $ip): void
179 { 179 {
@@ -189,7 +189,7 @@ class Context @@ -189,7 +189,7 @@ class Context
189 } 189 }
190 190
191 /** 191 /**
192 - * @param array $input 192 + * @param array $input
193 */ 193 */
194 public function setInput(array $input): void 194 public function setInput(array $input): void
195 { 195 {
@@ -205,7 +205,7 @@ class Context @@ -205,7 +205,7 @@ class Context
205 } 205 }
206 206
207 /** 207 /**
208 - * @param array $extras 208 + * @param array $extras
209 */ 209 */
210 public function setExtras(array $extras): void 210 public function setExtras(array $extras): void
211 { 211 {
@@ -227,8 +227,8 @@ class Context @@ -227,8 +227,8 @@ class Context
227 { 227 {
228 return [ 228 return [
229 'exception' => $this->exception, 'message' => $this->message, 'ip' => $this->ip, 'code' => $this->code, 229 'exception' => $this->exception, 'message' => $this->message, 'ip' => $this->ip, 'code' => $this->code,
230 - 'line' => $this->line, 'file' => $this->file, 'trace' => $this->trace, 'path' => $this->path,  
231 - 'method' => $this->method, 'agents' => $this->agents, 'input' => $this->input 230 + 'line' => $this->line, 'file' => $this->file, 'trace' => $this->trace, 'path' => $this->path,
  231 + 'method' => $this->method, 'agents' => $this->agents, 'input' => $this->input
232 ]; 232 ];
233 } 233 }
234 234
@@ -16,7 +16,7 @@ class Client @@ -16,7 +16,7 @@ class Client
16 public function __construct(string $baseUri) 16 public function __construct(string $baseUri)
17 { 17 {
18 $this->engine = new \GuzzleHttp\Client([ 18 $this->engine = new \GuzzleHttp\Client([
19 - 'base_uri' => $baseUri, RequestOptions::TIMEOUT => ExceptionPush::config('client.timeout', 30), 19 + 'base_uri' => $baseUri, RequestOptions::TIMEOUT => ExceptionPush::config('client.timeout', 30),
20 RequestOptions::VERIFY => false 20 RequestOptions::VERIFY => false
21 ]); 21 ]);
22 } 22 }
@@ -6,5 +6,5 @@ interface AgentInterface @@ -6,5 +6,5 @@ interface AgentInterface
6 { 6 {
7 public function report(array $content); 7 public function report(array $content);
8 8
9 - public function dsiabled(): bool; 9 + public function disabled(): bool;
10 } 10 }
@@ -8,7 +8,7 @@ use Throwable; @@ -8,7 +8,7 @@ use Throwable;
8 class Handler extends BaseHandler 8 class Handler extends BaseHandler
9 { 9 {
10 /** 10 /**
11 - * @param Throwable $e 11 + * @param Throwable $e
12 * 12 *
13 * @return void 13 * @return void
14 * @throws Throwable 14 * @throws Throwable
@@ -29,7 +29,7 @@ class Handler extends BaseHandler @@ -29,7 +29,7 @@ class Handler extends BaseHandler
29 } 29 }
30 30
31 /** 31 /**
32 - * @param Throwable $e 32 + * @param Throwable $e
33 * 33 *
34 * @return void 34 * @return void
35 */ 35 */
@@ -31,7 +31,7 @@ class ExceptionPush @@ -31,7 +31,7 @@ class ExceptionPush
31 */ 31 */
32 public static function getAgents($options = null): array 32 public static function getAgents($options = null): array
33 { 33 {
34 - $agentOpts = $options ? : (array) static::config('agents'); 34 + $agentOpts = $options ?: (array)static::config('agents');
35 35
36 $agents = []; 36 $agents = [];
37 37
@@ -94,7 +94,7 @@ class ExceptionPush @@ -94,7 +94,7 @@ class ExceptionPush
94 } 94 }
95 95
96 /** 96 /**
97 - * @param array $body 97 + * @param array $body
98 * 98 *
99 * @return void 99 * @return void
100 */ 100 */
@@ -16,7 +16,7 @@ class ExceptionPushProvider extends ServiceProvider @@ -16,7 +16,7 @@ class ExceptionPushProvider extends ServiceProvider
16 public function boot() 16 public function boot()
17 { 17 {
18 if ($this->app->runningInConsole()) { 18 if ($this->app->runningInConsole()) {
19 - $configPath = __DIR__.'/../publish/exception.push.php'; 19 + $configPath = __DIR__ . '/../publish/exception.push.php';
20 $this->publishes([ 20 $this->publishes([
21 $configPath => config_path('exception.push.php') 21 $configPath => config_path('exception.push.php')
22 ], 'lackoxygen-exception-push'); 22 ], 'lackoxygen-exception-push');
@@ -15,12 +15,12 @@ class Formatter implements CallbackInterface @@ -15,12 +15,12 @@ class Formatter implements CallbackInterface
15 { 15 {
16 return function (Context $context) { 16 return function (Context $context) {
17 return [ 17 return [
18 - '时间:'.Carbon::now()->toDateTimeString(), '环境:'.config('app.env'), '项目:'.config('app.name'),  
19 - '参数:'.json_encode($context->getInput()), 'runtime:'.php_sapi_name(), '地址:'.$context->getPath(),  
20 - '请求方法:'.$context->getMethod(), 'IP:'.$context->getIp(),  
21 - '异常:'.sprintf('%s(%s)(code:%d):at %s:%d', $context->getException(), $context->getMessage(), 18 + '时间:' . Carbon::now()->toDateTimeString(), '环境:' . config('app.env'), '项目:' . config('app.name'),
  19 + '参数:' . json_encode($context->getInput()), 'runtime:' . php_sapi_name(), '地址:' . $context->getPath(),
  20 + '请求方法:' . $context->getMethod(), 'IP:' . $context->getIp(),
  21 + '异常:' . sprintf('%s(%s)(code:%d):at %s:%d', $context->getException(), $context->getMessage(),
22 $context->getCode(), $context->getFile(), $context->getLine()), 22 $context->getCode(), $context->getFile(), $context->getLine()),
23 - 'trace:'.implode(PHP_EOL, $context->getTrace()), 23 + 'trace:' . implode(PHP_EOL, $context->getTrace()),
24 ]; 24 ];
25 }; 25 };
26 } 26 }
@@ -33,17 +33,18 @@ class MonologHandler extends AbstractSyslogHandler @@ -33,17 +33,18 @@ class MonologHandler extends AbstractSyslogHandler
33 protected array $channels = []; 33 protected array $channels = [];
34 34
35 /** 35 /**
36 - * @param array $channels 36 + * @param array $channels
37 * @param $facility 37 * @param $facility
38 * @param $level 38 * @param $level
39 - * @param bool $bubble 39 + * @param bool $bubble
40 */ 40 */
41 public function __construct( 41 public function __construct(
42 array $channels, 42 array $channels,
43 - $facility = LOG_USER,  
44 - $level = Logger::DEBUG,  
45 - bool $bubble = true  
46 - ) { 43 + $facility = LOG_USER,
  44 + $level = Logger::DEBUG,
  45 + bool $bubble = true
  46 + )
  47 + {
47 parent::__construct($facility, $level, $bubble); 48 parent::__construct($facility, $level, $bubble);
48 49
49 $this->dispatcher = Dispatcher::callback(); 50 $this->dispatcher = Dispatcher::callback();
@@ -52,7 +53,7 @@ class MonologHandler extends AbstractSyslogHandler @@ -52,7 +53,7 @@ class MonologHandler extends AbstractSyslogHandler
52 } 53 }
53 54
54 /** 55 /**
55 - * @param array $record 56 + * @param array $record
56 * 57 *
57 * @return void 58 * @return void
58 */ 59 */
@@ -32,7 +32,7 @@ class Parser @@ -32,7 +32,7 @@ class Parser
32 } 32 }
33 33
34 /** 34 /**
35 - * @param string $line 35 + * @param string $line
36 * 36 *
37 * @return string 37 * @return string
38 */ 38 */
@@ -42,7 +42,7 @@ class Parser @@ -42,7 +42,7 @@ class Parser
42 } 42 }
43 43
44 /** 44 /**
45 - * @param \Throwable $e 45 + * @param \Throwable $e
46 * 46 *
47 * @return void 47 * @return void
48 */ 48 */
@@ -53,7 +53,7 @@ class Parser @@ -53,7 +53,7 @@ class Parser
53 $this->context->setException(get_class($this->throw)); 53 $this->context->setException(get_class($this->throw));
54 $this->context->setMethod($this->request->getMethod()); 54 $this->context->setMethod($this->request->getMethod());
55 $this->context->setPath($this->request->path()); 55 $this->context->setPath($this->request->path());
56 - $this->context->setCode((string) $this->throw->getCode()); 56 + $this->context->setCode((string)$this->throw->getCode());
57 $this->context->setFile($this->realpath($this->throw->getFile())); 57 $this->context->setFile($this->realpath($this->throw->getFile()));
58 $this->context->setLine($this->throw->getLine()); 58 $this->context->setLine($this->throw->getLine());
59 $this->context->setMessage($this->throw->getMessage()); 59 $this->context->setMessage($this->throw->getMessage());