Completed
Push — master ( 5649ba...c37d73 )
by recca
03:09
created

polyfill.php ➔ tap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 10
rs 9.4285
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