Skip to content

Commit 013f619

Browse files
authored
Merge pull request #15 from BinarCode/stan
Adding a config whether to enable or not slack.
2 parents 004119c + a72e151 commit 013f619

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

config/developer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
'model' => \Binarcode\LaravelDeveloper\Models\DeveloperLog::class,
1313

1414
/**
15-
* The slack incoming webhook to send notifications.
15+
* Indicate whether to allow using slack helper.
16+
*/
17+
'slack_dev_enabled' => env('SLACK_DEV_LOG_ENABLED', true),
18+
19+
/**
20+
* The slack webhook to send notifications.
1621
*/
1722
'slack_dev_hook' => env('SLACK_DEV_HOOK'),
1823

src/Notifications/Slack.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ public function channel(string $channel): self
5757
return $this;
5858
}
5959

60-
private function send($item)
60+
private function send($item): self
6161
{
62+
if (! config('developer.slack_dev_enabled')) {
63+
return $this;
64+
}
65+
6266
/**
6367
* @var string $class
6468
*/

tests/Helpers/SlackHelperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class SlackHelperTest extends TestCase
1515
{
16-
public function test_slack_helper_returns_laravel_developer_instance()
16+
public function test_slack_helper_returns_laravel_developer_instance(): void
1717
{
1818
Notification::fake();
1919

@@ -22,7 +22,7 @@ public function test_slack_helper_returns_laravel_developer_instance()
2222
$this->assertInstanceOf(Slack::class, slack(new Exception()));
2323
}
2424

25-
public function test_slack_helper_can_send_message_to_slack()
25+
public function test_slack_helper_can_send_message_to_slack(): void
2626
{
2727
Notification::fake();
2828

@@ -31,7 +31,7 @@ public function test_slack_helper_can_send_message_to_slack()
3131
Notification::assertSentTo(new AnonymousNotifiable(), DevNotification::class);
3232
}
3333

34-
public function test_slack_helper_can_send_throwable_to_slack()
34+
public function test_slack_helper_can_send_throwable_to_slack(): void
3535
{
3636
Notification::fake();
3737

@@ -54,11 +54,11 @@ public function test_slack_helper_can_send_throwable_to_slack()
5454
DevNotification::class,
5555
function (DevNotification $class) use ($uuid) {
5656
return $class->notificationDto->attachment_link === "app.test/{$uuid}";
57-
}
57+
},
5858
);
5959
}
6060

61-
public function test_slack_helper_can_send_notifications_to_slack()
61+
public function test_slack_helper_can_send_notifications_to_slack(): void
6262
{
6363
Notification::fake();
6464

@@ -68,7 +68,7 @@ public function test_slack_helper_can_send_notifications_to_slack()
6868
]);
6969

7070
$this->assertInstanceOf(Slack::class, slack(
71-
new DummyNotification()
71+
new DummyNotification(),
7272
)->persist());
7373

7474
Notification::assertSentTo(new AnonymousNotifiable(), DummyNotification::class);

0 commit comments

Comments
 (0)