CallbackWriter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A writeItem() 0 4 1
1
<?php
2
3
namespace Ddeboer\DataImport\Writer;
4
5
use Ddeboer\DataImport\Writer;
6
7
/**
8
 * Writes using a callback or closure
9
 *
10
 * @author Markus Bachmann <[email protected]>
11
 */
12
class CallbackWriter implements Writer
13
{
14
    use WriterTemplate;
15
16
    /**
17
     * @var callable
18
     */
19
    private $callback;
20
21
    /**
22
     * @param callable $callback
23
     */
24 4
    public function __construct(callable $callback)
25
    {
26 4
        $this->callback = $callback;
27 4
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function writeItem(array $item)
33
    {
34 1
        call_user_func($this->callback, $item);
35 1
    }
36
}
37