ArrayReader::__construct()   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
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of plumphp/plum.
5
 *
6
 * (c) Florian Eckerstorfer <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Plum\Plum\Reader;
12
13
use ArrayIterator;
14
15
/**
16
 * ArrayReader.
17
 *
18
 * @author    Florian Eckerstorfer <[email protected]>
19
 * @copyright 2014-2016 Florian Eckerstorfer
20
 */
21
class ArrayReader implements ReaderInterface
22
{
23
    /** @var array */
24
    private $data = [];
25
26
    /**
27
     * @param array $data
28
     */
29 1
    public function __construct(array $data)
30
    {
31 1
        $this->data = $data;
32 1
    }
33
34
    /**
35
     * @return array
36
     */
37 1
    public function getData()
38
    {
39 1
        return $this->data;
40
    }
41
42
    /**
43
     * @return ArrayIterator
44
     */
45 1
    public function getIterator()
46
    {
47 1
        return new ArrayIterator($this->data);
48
    }
49
50
    /**
51
     * Returns the number of elements in the array.
52
     *
53
     * @return int
54
     */
55 1
    public function count()
56
    {
57 1
        return count($this->data);
58
    }
59
}
60