Completed
Push — master ( 1fa072...85af29 )
by Mads
06:24
created

WebhookProcessor::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fenerum\Webhooks;
6
7
use Illuminate\Support\Str;
8
9
class WebhookProcessor
10
{
11
    /**
12
     * @param string $event
13
     * @param array $data
14
     * @return bool
15
     */
16
    public static function handle(string $event, array $data): bool
17
    {
18
        $class = 'Fenerum\\Webhooks\\Events\\' . Str::studly(str_replace('.', '_', $event));
19
        if (\class_exists($class)) {
20
            event(new $class($event, $data));
21
22
            return true;
23
        }
24
25
        return false;
26
    }
27
}
28