Commit 271fbbbb authored by Taylor Otwell's avatar Taylor Otwell

added default parameter to file::get method.

parent 13d631e3
<?php namespace Laravel;
<?php namespace Laravel; use Closure;
class File {
......@@ -16,12 +16,26 @@ class File {
/**
* Get the contents of a file.
*
* <code>
* // Get the contents of a file
* $contents = File::get(APP_PATH.'routes'.EXT);
*
* // Get the contents of a file or return a default value if it doesn't exist
* $contents = File::get(APP_PATH.'routes'.EXT, 'Default Value');
* </code>
*
* @param string $path
* @param mixed $default
* @return string
*/
public static function get($path)
public static function get($path, $default = null)
{
return file_get_contents($path);
if (file_exists($path))
{
return file_get_contents($path);
}
return ($default instanceof Closure) ? call_user_func($default) : $default;
}
/**
......
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