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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

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