Completed
Pull Request — master (#5)
by Carlos C
13:10
created

DataArray::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace GenericCollections\Internal;
2
3
/**
4
 * This is a internal class to implement a protected property $data
5
 * that works like the internal storage for classes on this package.
6
 *
7
 * It also contains small methods to work with the array as a variable,
8
 * not in its contains. This follow the StorageInterface
9
 *
10
 * @package GenericCollections\Abstracts
11
 */
12
abstract class DataArray implements StorageInterface
13
{
14
    /**
15
     * Local storage for members
16
     *
17
     * @var array
18
     */
19
    protected $data = [];
20
21 3
    public function isEmpty()
22
    {
23 3
        return (0 === count($this->data));
24
    }
25
26 48
    public function toArray()
27
    {
28 48
        return $this->data;
29
    }
30
31 3
    public function clear()
32
    {
33 3
        $this->data = [];
34 3
    }
35
36 45
    public function count()
37
    {
38 45
        return count($this->data);
39
    }
40
41 3
    public function getIterator()
42
    {
43 3
        return new \ArrayIterator($this->data);
44
    }
45
}
46