Skip to content

Commit

Permalink
Add Coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul Mauricio Uñate Castro committed Jul 1, 2024
1 parent 73f5e1b commit 354d8c5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ function class_uses_recursive($class)
}
}

if (! function_exists('coalesce')) {
/**
* Returns the first non-null value from the given arguments.
*
* @param mixed ...$values
* @return mixed|null
*/
function coalesce(...$values)
{
foreach ($values as $value) {
if ($value !== null) {
return $value;
}
}

return null;
}
}

if (! function_exists('e')) {
/**
* Encode HTML special characters in a string.
Expand Down

0 comments on commit 354d8c5

Please sign in to comment.