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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 29
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A current() 0 9 2
A next() 0 6 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
/**
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