CallbackHandler::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
namespace Modulate\Artisan\Interceptor\Handlers;
4
5
use Modulate\Artisan\Interceptor\Contracts\Handler;
6
7
use Modulate\Artisan\Interceptor\InterceptedCommand;
8
use Symfony\Component\Console\Application;
9
use LogicException;
10
class CallbackHandler implements Handler
11
{
12
13
    /**
14
     * @var callable
15
     */
16
    protected $callable;
17
18
19 6
    public function __construct(
20
        callable $callable,
21
    ) {
22 6
        $this->callable = $callable;
23
    }
24
25
    /**
26
     * The check method is called to determine if the closure should be called.
27
     * In the case of the callback handler it will always return true
28
     *
29
     * @param InterceptedCommand $intercepted
30
     * @return boolean
31
     */
32 4
    public function check(InterceptedCommand $intercepted): bool 
33
    {
34 4
        return true;
35
    }
36
37 4
    public function handle(InterceptedCommand $intercepted): void
38
    {
39 4
        if ($this->callable) {
40 4
            call_user_func($this->callable, $intercepted);
41
        }
42
    }
43
}
44