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

EventHandlerReference   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getInboundEventClass() 0 3 1
A create() 0 3 1
A getHandlerMethodName() 0 3 1
A __construct() 0 5 1
A getEventName() 0 3 1
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
}