Completed
Push — master ( 6054f8...3b037a )
by Matthias
24:24
created

XMLReader::readNext()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 16
Code Lines 7

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 16
rs 8.8571
cc 6
eloc 7
nc 4
nop 2
1
<?php
2
3
namespace Cauditor\Analyzers;
4
5
use XMLReader as OriginalXMLReader;
6
7
/**
8
 * @author Matthias Mullie <[email protected]>
9
 * @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved.
10
 * @license LICENSE MIT
11
 */
12 View Code Duplication
class XMLReader extends OriginalXMLReader
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * This is a blend of XMLReader's read & next, in that it accepts a node
16
     * name to search for, but it doesn't assume the node if on the same level
17
     * in DOM hierarchy as where you're currently at: it won't skip children &
18
     * it will cross parents (unless.
19
     *
20
     * @param string $name   Name of the node we're looking for.
21
     * @param string $parent Name of parent node(s) to stay inside of.
22
     *
23
     * @return bool
24
     */
25
    public function readNext($name, $parent = null)
26
    {
27
        while ($this->read()) {
28
            // next node
29
            if ($this->localName === $name && $this->nodeType === self::ELEMENT) {
30
                return true;
31
            }
32
33
            // stop processing at and of this node
34
            if ($this->localName === $parent && $this->nodeType === self::END_ELEMENT) {
35
                return false;
36
            }
37
        }
38
39
        return false;
40
    }
41
}
42