Skip to content

Commit 4260b46

Browse files
harmbandstraSeldaek
authored andcommitted
SlackWebhookHandler: refactor curl_setopt to curl_setopt_array
1 parent 52d9096 commit 4260b46

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Monolog/Handler/SlackWebhookHandler.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,18 @@ protected function write(array $record)
8181
$postString = json_encode($postData);
8282

8383
$ch = curl_init();
84-
curl_setopt($ch, CURLOPT_URL, $this->webhookUrl);
85-
curl_setopt($ch, CURLOPT_POST, true);
86-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
84+
$options = [
85+
CURLOPT_URL => $this->webhookUrl,
86+
CURLOPT_POST => true,
87+
CURLOPT_RETURNTRANSFER => true,
88+
CURLOPT_HTTPHEADER => ['Content-type: application/json'],
89+
CURLOPT_POSTFIELDS => $postString
90+
];
8791
if (defined('CURLOPT_SAFE_UPLOAD')) {
88-
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
92+
$options[CURLOPT_SAFE_UPLOAD] = true;
8993
}
90-
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/json']);
91-
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
94+
95+
curl_setopt_array($ch, $options);
9296

9397
Curl\Util::execute($ch);
9498
}

0 commit comments

Comments
 (0)