CallbackHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 3 1
A handle() 0 4 2
A __construct() 0 4 1
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