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.
Completed
Push — master ( f49fbb...ecda1a )
by Dusan
01:23
created

MapIterator::current()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the iterators package.
4
 *
5
 * Copyright (c) Dusan Vejin
6
 *
7
 * For full copyright and license information, please refer to the LICENSE file,
8
 * located at the package root folder.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Dutek\Iterator;
14
15
/**
16
 * @author Dusan Vejin <[email protected]>
17
 */
18
final class MapIterator extends \IteratorIterator
19
{
20
    protected $callback;
21
    protected $callbackResult;
22
    protected $callbackResultCached;
23
24 2
    public function __construct(\Iterator $iterator, callable $callback)
25
    {
26 2
        parent::__construct($iterator);
27 2
        $this->callback = $callback;
28 2
    }
29
30 1
    public function current()
31
    {
32 1
        if (!$this->callbackResultCached) {
33 1
            $this->callbackResult = ($this->callback)(parent::current());
34 1
            $this->callbackResultCached = true;
35
        }
36
37 1
        return $this->callbackResult;
38
    }
39
40
    public function next()
41
    {
42
        parent::next();
43
        $this->callbackResult = null;
44
        $this->callbackResultCached = false;
45
    }
46
}
47