Completed
Push — master ( d26e7d...811b94 )
by Lars
02:24
created

ArrayyRewindableExtendedGenerator::current()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 10
loc 10
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arrayy;
6
7
/**
8
 * @template   XKey of array-key
9
 * @template   X
10
 * @extends    ArrayyRewindableGenerator<XKey,X>
11
 *
12
 * @internal
13
 */
14
class ArrayyRewindableExtendedGenerator extends ArrayyRewindableGenerator
15
{
16 1
    public function __construct(
17
        callable $generatorConstructionFunction,
18
        callable $onRewind = null,
19
        string $class = ''
20
    ) {
21 1
        parent::__construct(
22 1
            $generatorConstructionFunction,
23 1
            $onRewind,
24 1
            $class
25
        );
26 1
    }
27
28
    /**
29
     * Return the current element.
30
     *
31
     * @return mixed
32
     *
33
     * @see  http://php.net/manual/en/iterator.current.php
34
     * @see  Iterator::current
35
     *
36
     * @phpstan-return X
37
     */
38 1 View Code Duplication
    public function current()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40 1
        $value = $this->generator->current();
41
42 1
        if (\is_array($value)) {
43
            $value = \call_user_func([$this->class, 'create'], $value, static::class, false);
44
        }
45
46 1
        return $value;
47
    }
48
}
49