Passed
Push — main ( ed1bb6...4383ba )
by Slawomir
04:39
created

EventHandlerReference::getEventName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Infrastructure\Events\Api;
4
5
/**
6
 * Utility class that contains the name of the method that should be called upon an Inbound Event arrival,
7
 * and the class of appropriate Inbound Event.
8
 */
9
class EventHandlerReference
10
{
11
12 56
    private function __construct(
13
        private string $handlerMethodName,
14
        private string $inboundEventClass
15
    )
16
    {
17 56
    }
18
19
    /**
20
     * @return string
21
     */
22 2
    public function getHandlerMethodName(): string
23
    {
24 2
        return $this->handlerMethodName;
25
    }
26
27
    /**
28
     * @return string
29
     */
30 2
    public function getInboundEventClass(): string
31
    {
32 2
        return $this->inboundEventClass;
33
    }
34
35 56
    public static function create(string $handlerMethodName, string $inboundEventClass): EventHandlerReference
36
    {
37 56
        return new EventHandlerReference($handlerMethodName, $inboundEventClass);
38
    }
39
40
    public function getEventName(): string
41 1
    {
42
        return call_user_func($this->inboundEventClass . '::getName');
43
    }
44
45
46
}