Skip to content

Commit

Permalink
Adapter\Slack : we check if the curl extension is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rayanlevert committed Jul 13, 2023
1 parent fe4a46b commit ab347f5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Adapter/Slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Phalcon\Logger\AbstractLogger;
use Phalcon\Logger\Item;
use Phalcon\Logger\Exception;

/**
* Logger adapter to log messages into a Slack channel
Expand Down Expand Up @@ -50,8 +51,10 @@ class Slack extends \Phalcon\Logger\Adapter\AbstractAdapter
*/
public function __construct(string $token, string $channel)
{
if (!$this->curl = curl_init('https://slack.com/api/chat.postMessage')) {
throw new \Phalcon\Logger\Exception('curl_init() returned false');
if (!function_exists('curl_init')) {
throw new Exception('curl extension is not enabled');

Check warning on line 55 in src/Adapter/Slack.php

View check run for this annotation

Codecov / codecov/patch

src/Adapter/Slack.php#L55

Added line #L55 was not covered by tests
} elseif (!$this->curl = curl_init('https://slack.com/api/chat.postMessage')) {
throw new Exception('curl_init() returned false');

Check warning on line 57 in src/Adapter/Slack.php

View check run for this annotation

Codecov / codecov/patch

src/Adapter/Slack.php#L57

Added line #L57 was not covered by tests
}

$this->token = $token;
Expand Down

0 comments on commit ab347f5

Please sign in to comment.