Completed
Push — master ( 65570c...bf6ec7 )
by Arne
03:29 queued 12s
created

RecursiveIndexIterator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A current() 0 4 1
A hasChildren() 0 4 1
A getChildren() 0 4 1
1
<?php
2
3
namespace Storeman\Index;
4
5
class RecursiveIndexIterator extends \ArrayIterator implements \RecursiveIterator
6
{
7
    /**
8
     * @var IndexNode
9
     */
10
    protected $indexNode;
11
12
    public function __construct(IndexNode $indexNode)
13
    {
14
        $this->indexNode = $indexNode;
15
16
        parent::__construct($indexNode->getChildren());
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function current()
23
    {
24
        return parent::current()->getIndexObject();
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function hasChildren()
31
    {
32
        return count($this->indexNode) > 0;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getChildren()
39
    {
40
        return new static(parent::current());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (current() instead of getChildren()). Are you sure this is correct? If so, you might want to change this to $this->current().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
41
    }
42
}
43