ArrayWriter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 5
eloc 6
c 2
b 1
f 1
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prepare() 0 2 1
A finish() 0 2 1
A writeItem() 0 3 1
A __construct() 0 6 2
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