DataDoubleLinkedList::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
namespace GenericCollections\Internal;
3
4
abstract class DataDoubleLinkedList implements StorageInterface
5
{
6
    /**
7
     * Local storage for members
8
     *
9
     * @var DoubleLinkedList
10
     */
11
    protected $storage;
12
13
    /**
14
     * Create a new empty DoubleLinkedList and set it
15
     * on protected variable $storage
16
     *
17
     * @return void
18
     */
19
    abstract protected function createStorageObject();
20
21 1
    public function clear()
22
    {
23 1
        $this->storage->clear();
24 1
    }
25
26 26
    public function isEmpty()
27
    {
28 26
        return $this->storage->isEmpty();
29
    }
30
31 22
    public function toArray()
32
    {
33 22
        $array = [];
34 22
        foreach ($this->storage as $element) {
35 21
            $array[] = $element;
36
        }
37 22
        return $array;
38
    }
39
40 29
    public function count()
41
    {
42 29
        return $this->storage->count();
43
    }
44
45 1
    public function getIterator()
46
    {
47 1
        return new \IteratorIterator($this->storage);
48
    }
49
}
50