ArrayStorage::reader()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mathielen\ImportEngine\Storage;
4
5
use Ddeboer\DataImport\Reader\ArrayReader;
6
use Ddeboer\DataImport\Writer\ArrayWriter;
7
8
class ArrayStorage implements StorageInterface
9
{
10
    private $array;
11
12 14
    public function __construct(array &$array)
13
    {
14 14
        $this->array = &$array;
15 14
    }
16
17
    public function getFields()
18
    {
19
        return $this->reader()->getFields();
20
    }
21
22
    /**
23
     * (non-PHPdoc).
24
     *
25
     * @see \Mathielen\ImportEngine\Source\SourceInterface::reader()
26
     */
27 10
    public function reader()
28
    {
29 10
        return new ArrayReader($this->array);
30
    }
31
32
    /**
33
     * (non-PHPdoc).
34
     *
35
     * @see \Mathielen\ImportEngine\Source\StorageInterface::writer()
36
     */
37 3
    public function writer()
38
    {
39 3
        return new ArrayWriter($this->array);
40
    }
41
42
    /**
43
     * (non-PHPdoc).
44
     *
45
     * @see \Mathielen\ImportEngine\Source\SourceInterface::info()
46
     */
47 1
    public function info()
48
    {
49 1
        return new StorageInfo(array(
50 1
            'name' => 'Array Storage',
51 1
            'format' => 'Array Storage',
52 1
            'count' => count($this->reader()),
53
        ));
54
    }
55
}
56