Completed
Push — nln-php7 ( 6680df...1a6b54 )
by Nicolas
02:06
created

CallbackProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 22
ccs 6
cts 8
cp 0.75
rs 10
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Karma\FormatterProviders;
6
7
use Karma\Formatter;
8
use Karma\FormatterProvider;
9
10
class CallbackProvider implements FormatterProvider
11
{
12
    private \Closure
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_NS_SEPARATOR, expecting T_FUNCTION or T_CONST
Loading history...
13
        $closure;
14
15 3
    public function __construct(\Closure $closure)
16
    {
17 3
        $this->closure = $closure;
18 3
    }
19
20
    public function hasFormatter(?string $index): bool
21
    {
22
        return true;
23
    }
24
25 3
    public function getFormatter(?string $fileExtension, ?string $index = null): Formatter
26
    {
27 3
        $closure = $this->closure;
28
29 3
        return $closure($fileExtension, $index);
30
    }
31
}
32