CallbackWriter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 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