PartialBench   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A benchPartial() 0 9 1
A benchNative() 0 11 1
1
<?php
2
3
use function Prelude\partial;
4
5
/**
6
 * @Revs(1000)
7
 * @Iterations(10)
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 benchPartial()
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 benchNative()
22
    {
23
        $fn = function ($x) {
24
            return function ($y) use ($x) {
25
                return $x + $y;
26
            };
27
        };
28
29
        $rest = $fn(10);
30
        $rest(50);
31
    }
32
}
33