• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NIT-Administrative-Systems / SysDev-laravel-soa / 21220108336

21 Jan 2026 05:55PM UTC coverage: 38.99% (-6.1%) from 45.13%
21220108336

Pull #185

github

web-flow
Merge 7fa0e283e into 35f9e968a
Pull Request #185: EventHub command protection and restyling

0 of 189 new or added lines in 8 files covered. (0.0%)

6 existing lines in 5 files now uncovered.

278 of 713 relevant lines covered (38.99%)

12.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Console/Commands/EventHub/WebhookToggle.php
1
<?php
2

3
namespace Northwestern\SysDev\SOA\Console\Commands\EventHub;
4

5
use Illuminate\Console\Command;
6
use Illuminate\Console\ConfirmableTrait;
7
use Northwestern\SysDev\SOA\Console\Commands\Concerns\ConfirmsEventHubChanges;
8
use Northwestern\SysDev\SOA\EventHub;
9

10
use function Laravel\Prompts\multiselect;
11
use function Laravel\Prompts\spin;
12

13
class WebhookToggle extends Command
14
{
15
    use ConfirmableTrait, ConfirmsEventHubChanges;
16

17
    protected $signature = 'eventhub:webhook:toggle {status : pause or unpause} {queues?* : one or more queues to toggle. if unspecified, all queues will be updated.}';
18

19
    protected $description = 'Pause or unpause webhook deliveries.';
20

21
    public function __construct(
22
        protected EventHub\Webhook $webhook_api
23
    ) {
NEW
24
        parent::__construct();
×
25
    }
26

27
    public function handle(): int
28
    {
NEW
29
        if (! $this->confirmWebhookToggle()) {
×
NEW
30
            $this->components->error('Command aborted.');
×
31

NEW
32
            return self::FAILURE;
×
33
        }
34

UNCOV
35
        $queues = [];
×
36

37
        $status = strtolower($this->argument('status'));
×
38
        if (in_array($status, ['pause', 'unpause']) === false) {
×
NEW
39
            $this->components->error('Invalid status. Please specify pause or unpause.');
×
40

NEW
41
            return self::FAILURE;
×
42
        }
43

44
        $specific_queues = $this->argument('queues');
×
45
        if (count($specific_queues) > 0) {
×
46
            $queues = $specific_queues;
×
47
        } else {
NEW
48
            $hooks = spin(
×
NEW
49
                fn () => $this->webhook_api->listAll(),
×
NEW
50
                'Fetching webhooks...'
×
NEW
51
            );
×
52

NEW
53
            $queues = collect($hooks['webhooks'])->pluck('topicName')->all();
×
54

NEW
55
            if (empty($queues)) {
×
NEW
56
                $this->components->warn('No webhooks found.');
×
57

NEW
58
                return self::SUCCESS;
×
59
            }
60
        }
61

62
        foreach ($queues as $queue) {
×
63
            try {
NEW
64
                spin(
×
NEW
65
                    fn () => $this->webhook_api->$status($queue),
×
NEW
66
                    ucfirst($status)."ing {$queue}..."
×
NEW
67
                );
×
68

NEW
69
                $this->components->info(ucfirst($status)."d <bg=magenta;fg=white;options=bold> {$queue} </>");
×
NEW
70
            } catch (EventHub\Exception\EventHubError $e) {
×
NEW
71
                $this->components->error("Unable to change status of <bg=magenta;fg=white;options=bold> {$queue} </>: {$e->getMessage()}");
×
NEW
72
                $this->newLine();
×
73
            }
74
        }
75

76
        // Display status after the changes are made.
77
        $this->call('eventhub:webhook:status');
×
78

NEW
79
        return self::SUCCESS;
×
80
    }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc