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

ArrayyRewindableExtendedGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 28.57 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
dl 10
loc 35
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A current() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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