CallableTransitionEventCallback::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 8
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dflydev\FiniteStateMachine\TransitionEvent;
6
7
use Closure;
8
use Dflydev\FiniteStateMachine\Contracts\Event;
9
use Dflydev\FiniteStateMachine\Contracts\TransitionEventCallback;
10
use Dflydev\FiniteStateMachine\State\State;
11
use Dflydev\FiniteStateMachine\Transition\Transition;
12
13
class CallableTransitionEventCallback implements TransitionEventCallback
14
{
15
    /**
16
     * @var callable
17
     */
18
    private $callable;
19
20
    /**
21
     * @param callable $callable
22
     */
23 21
    public function __construct($callable)
24
    {
25 21
        $this->callable = $callable;
26 21
    }
27
28 1
    public function __invoke(
29
        string $when,
30
        object $object,
31
        Transition $transition,
32
        State $fromState,
33
        State $toState
34
    ): void {
35 1
        ($this->callable)($when, $object, $transition, $fromState, $toState);
36 1
    }
37
}
38