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 ( bd74f9...c38dae )
by Daniel
09:23
created

FilterOneMillionItems::benchCollectionArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
namespace Narrowspark\Collection;
4
5
use Narrowspark\Collection\Collection;
6
7
class FilterOneMillionItems
8
{
9
    const ONE_MILLION = 1000000;
10
11
    /**
12
     * @Revs(10)
13
     */
14 View Code Duplication
    public function benchCollectionArray()
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...
15
    {
16
        $collection = Collection::from(range(0, static::ONE_MILLION));
17
18
        $result = $collection->filter(function ($i) {
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
            return $i % 2 === 0;
20
        });
21
    }
22
23
    /**
24
     * @Revs(10)
25
     */
26
    public function benchNativeArrayFilter()
27
    {
28
        $result = array_filter(range(0, static::ONE_MILLION), function ($i) {
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
            return $i % 2 === 0;
30
        });
31
    }
32
33
    /**
34
     * @Revs(10)
35
     */
36
    public function benchForEachArray()
37
    {
38
        $items = range(0, static::ONE_MILLION);
39
        $filtered = [];
40
        foreach ($items as $i => $item) {
41
            if ($i % 2 === 0) {
42
                $filtered[$i] = $item;
43
            }
44
        }
45
    }
46
}
47