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 — develop ( 7ab88f...fff013 )
by Baptiste
07:46
created

Accumulate   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 68
ccs 27
cts 27
cp 1
rs 10
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 5 1
A pop() 0 5 2
A valid() 0 3 2
A key() 0 5 1
A next() 0 7 2
A reachedCacheEnd() 0 3 1
A __construct() 0 3 1
A rewind() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable;
5
6
/**
7
 * Simple iterator to cache the results of a generator so it can be iterated
8
 * over multiple times
9
 *
10
 * @template T
11
 * @template S
12
 * @internal Do not use this in your code
13
 */
14
final class Accumulate implements \Iterator
15
{
16
    /** @var \Generator<T, S> */
17
    private \Generator $generator;
18
    /** @var list<T> */
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
    private array $keys = [];
20
    /** @var list<S> */
21
    private array $values = [];
22
23
    /**
24
     * @param \Generator<T, S> $generator
25
     */
26 72
    public function __construct(\Generator $generator)
27
    {
28 72
        $this->generator = $generator;
29 72
    }
30
31
    /**
32
     * @return S
33
     */
34 60
    public function current()
35
    {
36 60
        $this->pop();
37
38 60
        return \current($this->values);
39
    }
40
41
    /**
42
     * @return T
43
     */
44 41
    public function key()
45
    {
46 41
        $this->pop();
47
48 41
        return \current($this->keys);
49
    }
50
51 56
    public function next(): void
52
    {
53 56
        \next($this->keys);
54 56
        \next($this->values);
55
56 56
        if ($this->reachedCacheEnd()) {
57 56
            $this->generator->next();
58
        }
59 56
    }
60
61 67
    public function rewind(): void
62
    {
63 67
        \reset($this->keys);
64 67
        \reset($this->values);
65 67
    }
66
67 67
    public function valid(): bool
68
    {
69 67
        return !$this->reachedCacheEnd() || $this->generator->valid();
70
    }
71
72 67
    private function reachedCacheEnd(): bool
73
    {
74 67
        return \key($this->values) === null;
75
    }
76
77 60
    private function pop(): void
78
    {
79 60
        if ($this->reachedCacheEnd()) {
80 60
            $this->keys[] = $this->generator->key();
81 60
            $this->values[] = $this->generator->current();
82
        }
83 60
    }
84
}
85