added default parameter to file::get method.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?php namespace Laravel;
|
<?php namespace Laravel; use Closure;
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
|
|
||||||
@@ -16,14 +16,28 @@ class File {
|
|||||||
/**
|
/**
|
||||||
* Get the contents of a 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 string $path
|
||||||
|
* @param mixed $default
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get($path)
|
public static function get($path, $default = null)
|
||||||
|
{
|
||||||
|
if (file_exists($path))
|
||||||
{
|
{
|
||||||
return file_get_contents($path);
|
return file_get_contents($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ($default instanceof Closure) ? call_user_func($default) : $default;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to a file.
|
* Write to a file.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user