Commit 65ffe0b6 authored by Taylor Otwell's avatar Taylor Otwell

Added support for closures as Arr::get default parameter.

parent 1e84c890
......@@ -7,7 +7,7 @@ class Arr {
*
* @param array $array
* @param string $key
* @param array $default
* @param mixed $default
* @return mixed
*/
public static function get($array, $key, $default = null)
......@@ -17,7 +17,12 @@ class Arr {
return $array;
}
return (array_key_exists($key, $array)) ? $array[$key] : $default;
if (array_key_exists($key, $array))
{
return $array[$key];
}
return is_callable($default) ? call_user_func($default) : $default;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment