Passed
Pull Request — master (#1117)
by Aleksei
22:58 queued 12:19
created

CallableHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Interceptors\Handler;
6
7
use Spiral\Interceptors\Context\CallContextInterface;
8
use Spiral\Interceptors\HandlerInterface;
9
10
/**
11
 * Handler that just invokes PHP callable without any additional logic.
12
 */
13
final class CallableHandler implements HandlerInterface
14
{
15 4
    public function handle(CallContextInterface $context): mixed
16
    {
17 4
        $callable = $context->getTarget()->getCallable();
18 4
        \is_callable($callable) or throw new \RuntimeException('Callable not found in the call context.');
19
20 3
        return $callable(...$context->getArguments());
21
    }
22
}
23