Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
fix function tap
Browse files Browse the repository at this point in the history
  • Loading branch information
xleliu committed Aug 14, 2017
1 parent 61da07e commit 42f6c65
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,19 @@ function value($value)
return $value instanceof Closure ? $value() : $value;
}
}

if (! function_exists('tap')) {
/**
* Call the given Closure with the given value then return the value.
*
* @param mixed $value
* @param callable $callback
* @return mixed
*/
function tap($value, $callback)
{
$callback($value);

return $value;
}
}

0 comments on commit 42f6c65

Please sign in to comment.