Passed
Push — master ( 429e9a...22d25f )
by Sérgio
05:09
created

PartialBench::benchPartial2Args()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
use function Prelude\partial;
4
5
/**
6
 * @Revs(1000)
7
 * @Iterations(5)
8
 */
9
class PartialBench
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    public function benchPartial2Args()
12
    {
13
        $fn = partial(function ($x, $y) {
14
            return $x + $y;
15
        });
16
17
        $rest = $fn(10);
18
        $rest(50);
19
    }
20
21
    public function benchPartialNativeFn()
22
    {
23
        $alpha = ['a', 'b', 'c', 'd', 'f'];
24
        $fn = partial('array_slice');
25
26
        $fn($alpha, 2);
27
        $fn($alpha, -2, 1);
28
        $fn($alpha, 0, 3);
29
    }
30
}
31