We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08781be commit 3b15285Copy full SHA for 3b15285
src/Illuminate/Support/helpers.php
@@ -377,3 +377,18 @@ function with($value, callable $callback = null)
377
return is_null($callback) ? $value : $callback($value);
378
}
379
380
+
381
+if (! function_exists('when')) {
382
+ /**
383
+ * If condition is true call the given Closure with the condition value then return the result.
384
+ *
385
+ * @param mixed $condition
386
+ * @param callable $callback
387
+ * @param mixed $otherwise
388
+ * @return mixed
389
+ */
390
+ function when($condition, callable $callback, $otherwise = null)
391
+ {
392
+ return $condition ? $callback($condition) : $otherwise;
393
+ }
394
+}
0 commit comments