WebhookEventDispatcher::dispatch()   B
last analyzed

Complexity

Conditions 9
Paths 9

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 25
c 0
b 0
f 0
nc 9
nop 1
dl 0
loc 27
rs 8.0555
1
<?php
2
3
namespace SquareetLabs\LaravelOpenVidu\Dispatchers;
4
5
use Illuminate\Support\Facades\Event;
6
use SquareetLabs\LaravelOpenVidu\Events\FilterEventDispatched;
7
use SquareetLabs\LaravelOpenVidu\Events\ParticipantJoined;
8
use SquareetLabs\LaravelOpenVidu\Events\ParticipantLeft;
9
use SquareetLabs\LaravelOpenVidu\Events\RecordingStatusChanged;
10
use SquareetLabs\LaravelOpenVidu\Events\SessionCreated;
11
use SquareetLabs\LaravelOpenVidu\Events\SessionDestroyed;
12
use SquareetLabs\LaravelOpenVidu\Events\WebRTCConnectionCreated;
13
use SquareetLabs\LaravelOpenVidu\Events\WebRTCConnectionDestroyed;
14
15
/**
16
 * Class WebhookEventFactory
17
 * @package SquareetLabs\LaravelOpenVidu\Factories
18
 */
19
class WebhookEventDispatcher
20
{
21
    public static function dispatch(array $webhookEvent)
22
    {
23
        switch ($webhookEvent['event']) {
24
            case 'sessionCreated':
25
                Event::dispatch(new SessionCreated($webhookEvent));
26
                break;
27
            case 'sessionDestroyed':
28
                Event::dispatch(new SessionDestroyed($webhookEvent));
29
                break;
30
            case 'participantJoined':
31
                Event::dispatch(new ParticipantJoined($webhookEvent));
32
                break;
33
            case 'participantLeft':
34
                Event::dispatch(new ParticipantLeft($webhookEvent));
35
                break;
36
            case 'webrtcConnectionCreated':
37
                Event::dispatch(new WebRTCConnectionCreated($webhookEvent));
38
                break;
39
            case 'webrtcConnectionDestroyed':
40
                Event::dispatch(new WebRTCConnectionDestroyed($webhookEvent));
41
                break;
42
            case 'recordingStatusChanged':
43
                Event::dispatch(new RecordingStatusChanged($webhookEvent));
44
                break;
45
            case 'filterEventDispatched':
46
                Event::dispatch(new FilterEventDispatched($webhookEvent));
47
                break;
48
        }
49
    }
50
}