GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RangeIterator   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A doRewind() 0 5 1
B doFetch() 0 14 5
1
<?php
2
3
namespace Pinq\Iterators\Standard;
4
5
use Pinq\Iterators\Common;
6
7
/**
8
 * Implementation of the range iterator using the fetch method.
9
 *
10
 * @author Elliot Levin <[email protected]>
11
 */
12
class RangeIterator extends IteratorIterator
13
{
14
    use Common\RangeIterator;
15
16
    /**
17
     * @var int
18
     */
19
    private $position = 0;
20
21
    public function __construct(IIterator $iterator, $startAmount, $rangeAmount)
22
    {
23
        parent::__construct($iterator);
24
        self::__constructIterator($startAmount, $rangeAmount);
25
    }
26
27
    public function doRewind()
28
    {
29
        $this->position = 0;
30
        parent::doRewind();
31
    }
32
33
    protected function doFetch()
34
    {
35
        while ($element = $this->iterator->fetch()) {
36
            if ($this->endPosition !== null && $this->position >= $this->endPosition) {
37
                return null;
38
            } elseif ($this->position >= $this->startPosition) {
39
                $this->position++;
40
41
                return $element;
42
            } else {
43
                $this->position++;
44
            }
45
        }
46
    }
47
}
48