polyfill.php ➔ tap()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 10
ccs 0
cts 4
cp 0
crap 6
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
use Recca0120\Repository\HigherOrderTapProxy;
4
5
if (! function_exists('tap')) {
6
    /**
7
     * Call the given Closure with the given value then return the value.
8
     *
9
     * @param  mixed  $value
10
     * @param  callable|null  $callback
11
     * @return mixed
12
     */
13
    function tap($value, $callback = null)
14
    {
15
        if (is_null($callback)) {
16
            return new HigherOrderTapProxy($value);
17
        }
18
19
        $callback($value);
20
21
        return $value;
22
    }
23
}
24