Completed
Push — work-fleets ( 4ec5b3...fe2ede )
by SuperNova.WS
10:06
created

V2UnitIterator::rewind()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 2
b 0
f 1
ccs 0
cts 6
cp 0
crap 6
1
<?php
2
3
namespace V2Unit;
4
5
6
/**
7
 * Class V2UnitIterator
8
 *
9
 * @method V2UnitIterator getInnerIterator()
10
 *
11
 * @package V2Unit
12
 */
13
class V2UnitIterator extends \IteratorIterator {
14
15
  protected $type = 0;
16
17
  public function setFilterType($type) {
18
    $this->type = $type;
19
  }
20
21
  protected function filterCurrent() {
22
    return
23
      $this->valid()
24
      &&
25
      $this->filterType();
26
  }
27
28
  protected function filterType() {
29
    $inner = $this->getInnerIterator();
30
    return
31
      $this->type
32
      &&
33
      (
34
        !$inner->current()->type
35
        ||
36
        $inner->current()->type != $this->type
37
      );
38
  }
39
40
  public function next() {
41
    do {
42
      $this->getInnerIterator()->next();
43
    } while ($this->filterCurrent());
44
  }
45
46
  public function rewind() {
47
//    parent::rewind(); // TODO: Not working
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
    $this->getInnerIterator()->rewind();
49
50
    // If first element not of supplied type - finding first available element
51
    if ($this->filterCurrent()) {
52
      $this->next();
53
    }
54
  }
55
56
  // TODO - why it's not forwarded ??????????s
57
  public function valid() {
58
    return $this->getInnerIterator()->valid();
59
  }
60
61
  /**
62
   * @return V2UnitContainer
63
   */
64
  public function current() {
65
    return $this->getInnerIterator()->current();
66
  }
67
68
  public function key() {
69
    return $this->getInnerIterator()->key();
70
  }
71
72
}
73