Completed
Push — master ( 2f0783...0fb3d7 )
by Markus
03:33
created

ArrayStorage::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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