ArtisanCallbackHandler::check()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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