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.

MapIterator::next()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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
use IteratorIterator;
16
17
final class MapIterator extends IteratorIterator
18
{
19
    protected $callback;
20
    protected $callbackResult;
21
    protected $callbackResultCached;
22
23 5
    public function __construct(iterable $iterable, callable $callback)
24
    {
25 5
        parent::__construct($iterable);
26 5
        $this->callback = $callback;
27 5
    }
28
29 4
    public function current()
30
    {
31 4
        if (!$this->callbackResultCached) {
32 4
            $this->callbackResult = ($this->callback)(parent::current());
33 4
            $this->callbackResultCached = true;
34
        }
35
36 4
        return $this->callbackResult;
37
    }
38
39 3
    public function next()
40
    {
41 3
        parent::next();
42 3
        $this->callbackResult = null;
43 3
        $this->callbackResultCached = false;
44 3
    }
45
}
46