Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
271fbbbb
Commit
271fbbbb
authored
Dec 02, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added default parameter to file::get method.
parent
13d631e3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
file.php
laravel/file.php
+17
-3
No files found.
laravel/file.php
View file @
271fbbbb
<?php
namespace
Laravel
;
<?php
namespace
Laravel
;
use
Closure
;
class
File
{
class
File
{
...
@@ -16,14 +16,28 @@ 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.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment