Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Add a more readable "missing" method to Filesystem and FilesystemAdapter #30441

Merged
merged 4 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add missing method to FilesystemAdapter
  • Loading branch information
AmirrezaNasiri committed Oct 27, 2019
commit 2912ca1c164972610c2ce57a3f474a0f8f27ceb7
11 changes: 11 additions & 0 deletions src/Illuminate/Filesystem/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ public function exists($path)
return $this->driver->has($path);
}

/**
* Determine if a file or directory is missing.
*
* @param string $path
* @return bool
*/
public function missing($path)
{
return !$this->exists($path);
}

/**
* Get the full path for the file at the given "short" path.
*
Expand Down
6 changes: 6 additions & 0 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public function testExists()
$this->assertTrue($filesystemAdapter->exists('file.txt'));
}

public function testMissing()
{
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertTrue($filesystemAdapter->missing('file.txt'));
}

public function testPath()
{
$this->filesystem->write('file.txt', 'Hello World');
Expand Down