QueryPathIterator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A current() 0 11 2
1
<?php
2
/**
3
 * @file
4
 *
5
 * Utility iterator for QueryPath.
6
 */
7
8
namespace QueryPath;
9
10
use QueryPath\QueryPath;
11
12
/**
13
 * An iterator for QueryPath.
14
 *
15
 * This provides iterator support for QueryPath. You do not need to construct
16
 * a QueryPathIterator. QueryPath does this when its QueryPath::getIterator()
17
 * method is called.
18
 *
19
 * @ingroup querypath_util
20
 */
21
class QueryPathIterator extends \IteratorIterator
22
{
23
24
    public $options = [];
25
    private $qp;
26
27
    public function current()
28
    {
29
        if (!isset($this->qp)) {
30
            $this->qp = QueryPath::with(parent::current(), NULL, $this->options);
31
        } else {
32
            $splos = new \SplObjectStorage();
33
            $splos->attach(parent::current());
34
            $this->qp->setMatches($splos);
35
        }
36
37
        return $this->qp;
38
    }
39
}
40