Skip to content

Commit ce3e63e

Browse files
authored
Create helpers.php
1 parent 118ed65 commit ce3e63e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/helpers.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
if (! function_exists('tap')) {
4+
/**
5+
* Call the given Closure with the given value then return the value.
6+
*
7+
* @param mixed $value
8+
* @param callable|null $callback
9+
* @return mixed
10+
*/
11+
function tap($value, $callback = null)
12+
{
13+
if (is_null($callback)) {
14+
if (class_exists(\Illuminate\Support\HigherOrderTapProxy::class)) {
15+
return new \HigherOrderTapProxy\HigherOrderTapProxy($value);
16+
}
17+
18+
return new \ZhenMu\Support\Utils\HigherOrderTapProxy($value);
19+
}
20+
21+
$callback($value);
22+
23+
return $value;
24+
}
25+
}

0 commit comments

Comments
 (0)