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::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
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