Test Failed
Pull Request — master (#1117)
by Aleksei
15:44
created

CallableHandler::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 1
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
    public function handle(CallContextInterface $context): mixed
16
    {
17
        $callable = $context->getTarget()->getCallable();
18
        \is_callable($callable) or throw new \RuntimeException('Callable not found in the call context.');
19
20
        return $callable(...$context->getArguments());
21
    }
22
}
23