ArrayWriter::writeItem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Jackal\Copycat\Writer;
4
5
/**
6
 * Class ArrayWriter
7
 * @package Jackal\Copycat\Writer
8
 */
9
class ArrayWriter implements WriterInterface
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $outItems;
15
16
    /**
17
     * ArrayWriter constructor.
18
     * @param $arrayToWrite
19
     */
20
    public function __construct(&$arrayToWrite)
21
    {
22
        if (!is_array($arrayToWrite)) {
23
            $arrayToWrite = [];
24
        }
25
        $this->outItems = &$arrayToWrite;
26
    }
27
28
    /**
29
     *
30
     */
31
    public function prepare()
32
    {
33
        //do nothing
34
    }
35
36
    /**
37
     * @param array $item
38
     */
39
    public function writeItem(array $item)
40
    {
41
        $this->outItems[] = $item;
42
    }
43
44
    /**
45
     *
46
     */
47
    public function finish()
48
    {
49
        //do nothing
50
    }
51
}
52