Completed
Push — 57-formatter-per-extension ( 73b3c8 )
by Nicolas
40:17 queued 36:16
created

CallbackProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 22
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hasFormatter() 0 4 1
A getFormatter() 0 6 1
1
<?php
2
3
namespace Karma\FormatterProviders;
4
5
use Karma\FormatterProvider;
6
7
class CallbackProvider implements FormatterProvider
8
{
9
    private
10
        $closure;
11
    
12
    public function __construct(\Closure $closure)
13
    {
14
        $this->closure = $closure;  
15
    }
16
    
17
    public function hasFormatter($index)
18
    {
19
        return true;
20
    }
21
22
    public function getFormatter($fileExtension, $index = null)
23
    {
24
        $closure = $this->closure;
25
        
26
        return $closure($fileExtension, $index);
27
    }
28
}