Skip to content

Commit 2071b04

Browse files
Add news report_if and report_unless helpers functions (#45093)
1 parent 437e1f0 commit 2071b04

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Illuminate/Foundation/helpers.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,38 @@ function report($exception)
681681
}
682682
}
683683

684+
if (! function_exists('report_if')) {
685+
/**
686+
* Report an exception if the given condition is true.
687+
*
688+
* @param bool $boolean
689+
* @param \Throwable|string $exception
690+
* @return void
691+
*/
692+
function report_if($boolean, $exception)
693+
{
694+
if ($boolean) {
695+
report($exception);
696+
}
697+
}
698+
}
699+
700+
if (! function_exists('report_unless')) {
701+
/**
702+
* Report an exception unless the given condition is true.
703+
*
704+
* @param bool $boolean
705+
* @param \Throwable|string $exception
706+
* @return void
707+
*/
708+
function report_unless($boolean, $exception)
709+
{
710+
if (! $boolean) {
711+
report($exception);
712+
}
713+
}
714+
}
715+
684716
if (! function_exists('request')) {
685717
/**
686718
* Get an instance of the current request or an input item from the request.

0 commit comments

Comments
 (0)