ApplyCallsWhenMethod   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 1
b 0
f 0
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 4 1
1
<?php declare(strict_types=1);
2
namespace Kepawni\Twilted\Basic;
3
4
use Kepawni\Twilted\DomainEvent;
5
use Verraes\ClassFunctions\ClassFunctions;
6
7
trait ApplyCallsWhenMethod
8
{
9
    /**
10
     * Delegate the application of the event to the appropriate when... method, e. g. a VisitorHasLeft event will be
11
     * processed by the (private) method whenVisitorHasLeft(VisitorHasLeft $event): void
12
     *
13
     * @param DomainEvent $event
14
     */
15
    protected function apply(DomainEvent $event): void
16
    {
17
        $method = 'when' . ClassFunctions::short($event->getPayload());
18
        $this->$method($event->getPayload(), $event);
19
    }
20
}
21