Collection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 6
c 6
b 0
f 0
lcom 1
cbo 0
dl 0
loc 41
ccs 15
cts 15
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getIteratorReversed() 0 7 1
A value() 0 4 1
A toArray() 0 4 1
A __construct() 0 11 3
1
<?php
2
3
namespace Underscore;
4
5
class Collection extends \ArrayObject
6
{
7 67
    public function __construct($input)
8
    {
9 67
        if (is_object($input)) {
10 36
            if ($input instanceof \Traversable) {
11 3
                $input = iterator_to_array($input);
12
            } else {
13 34
                $input = get_object_vars($input);
14
            }
15
        }
16 67
        parent::__construct($input, static::ARRAY_AS_PROPS);
17 67
    }
18
19
    /**
20
     * @return \ArrayIterator
21
     */
22 3
    public function getIteratorReversed()
23
    {
24 3
        $iterator = $this->getIteratorClass();
25 3
        $collection = array_reverse($this->getArrayCopy());
26
27 3
        return new $iterator($collection);
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33 11
    public function value()
34
    {
35 11
        return $this->toArray();
36
    }
37
38
    /**
39
     * @return mixed[]
40
     */
41 53
    public function toArray()
42
    {
43 53
        return $this->getArrayCopy();
44
    }
45
}
46