ArrayWriter::prepare()   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 0
crap 1
1
<?php
2
3
namespace Ddeboer\DataImport\Writer;
4
5
use Ddeboer\DataImport\Writer;
6
7
/**
8
 * This class writes an item into an array that was passed by reference
9
 *
10
 * @author David de Boer <[email protected]>
11
 */
12
class ArrayWriter implements Writer
13
{
14
    use WriterTemplate;
15
16
    /**
17
     * @var array
18
     */
19
    protected $data;
20
21
    /**
22
     * @param array $data
23
     */
24 5
    public function __construct(array &$data)
25
    {
26 5
        $this->data = &$data;
27 5
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 4
    public function prepare()
33
    {
34 4
        $this->data = [];
35 4
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function writeItem(array $item)
41
    {
42 2
        $this->data[] = $item;
43 2
    }
44
}
45