Completed
Push — master ( 6b5da6...9a1463 )
by Basenko
04:09
created

Callback   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 33
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A title() 0 6 1
A __invoke() 0 10 2
1
<?php
2
3
namespace MadWeb\Initializer\ExecutorActions;
4
5
use Illuminate\Console\Command;
6
7
class Callback
8
{
9
    private $artisanCommand;
10
11
    private $function;
12
13
    private $arguments;
14
15 6
    public function __construct(Command $artisanCommand, callable $function, array $arguments = [])
16
    {
17 6
        $this->artisanCommand = $artisanCommand;
18 6
        $this->function = $function;
19 6
        $this->arguments = $arguments;
20 6
    }
21
22 6
    private function title()
23
    {
24 6
        is_callable($this->function, false, $name);
25
26 6
        return '<comment>Calling function:</comment> '.$name;
27
    }
28
29 6
    public function __invoke(): bool
30
    {
31
        return $this->artisanCommand->task($this->title(), function () {
32 6
            if ($this->artisanCommand->getOutput()->isVerbose()) {
33
                $this->artisanCommand->getOutput()->newLine();
34
            }
35
36 6
            return call_user_func($this->function, ...$this->arguments);
37 6
        });
38
    }
39
}
40