CallableUnifierTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizeAsCallables() 0 9 2
1
<?php
2
3
namespace Pitchart\Collection\Mixin;
4
5
/**
6
 * A trait to unify callable calls syntaxes
7
 *
8
 * @author Julien VITTE <[email protected]>
9
 */
10
trait CallableUnifierTrait
11
{
12
    /**
13
     * Normalizes callbacks, closures and invokable objects calls
14
     *
15
     * @param callable $callable
16
     *
17
     * @return callable
18
     */
19 75
    private function normalizeAsCallables(callable $callable)
20
    {
21 75
        if (is_object($callable)) {
22 71
            return $callable;
23
        }
24 4
        return function () use ($callable) {
25 4
            return call_user_func_array($callable, func_get_args());
26 4
        };
27
    }
28
}
29