ChildIterator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A rewind() 0 5 1
A valid() 0 6 2
1
<?php
2
3
namespace Thruster\Component\XMLIterator;
4
5
/**
6
 * Class ChildIterator
7
 *
8
 * @package Thruster\Component\XMLIterator
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
class ChildIterator extends XMLIterator
12
{
13
    /**
14
     * @var int
15
     */
16
    private $stopDepth;
17
18
    public function __construct(XMLReader $reader)
19
    {
20
        parent::__construct($reader);
21
22
        $this->stopDepth = $reader->depth;
23
    }
24
25
    public function rewind()
26
    {
27
        parent::next();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (next() instead of rewind()). Are you sure this is correct? If so, you might want to change this to $this->next().

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...
28
        parent::rewind();
29
    }
30
31
    public function valid()
32
    {
33
        $parent = parent::valid();
34
35
        return $parent && ($this->reader->depth > $this->stopDepth);
36
    }
37
}
38