Completed
Push — master ( 982565...967e93 )
by Lyal
45:40 queued 43:25
created

EventHelper::getEventHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
eloc 0
nc 1
nop 0
1
<?php
2
3
namespace Lyal\Checkr\Laravel\Helpers;
4
5
use Lyal\Checkr\Exceptions\UnhandledCheckrWebhook;
6
7
class EventHelper
8
{
9
    private $event;
10
11
    public function __construct($event)
12
    {
13
        $this->event = $event;
14
    }
15
16
    public function dispatch()
17
    {
18
        $className = '\\Lyal\\Checkr\\Laravel\\Events\\'.studly_case(str_replace('.', '-', $this->event['type']));
19
        if (class_exists($className)) {
20
            event(new $className($this->event));
0 ignored issues
show
Bug introduced by
The function event was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
            /** @scrutinizer ignore-call */ 
21
            event(new $className($this->event));
Loading history...
21
        } else {
22
            throw new UnhandledCheckrWebhook($this->event);
23
        }
24
    }
25
26
    public function getEventHandler()
27
    {
28
    }
29
}
30