Skip to content

Commit

Permalink
use helper - rename option
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 3, 2022
1 parent dfebc33 commit 1e11a68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
42 changes: 11 additions & 31 deletions src/Illuminate/Filesystem/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ public function get($path)
try {
return $this->driver->read($path);
} catch (UnableToReadFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);
}
}

Expand Down Expand Up @@ -332,9 +330,7 @@ public function put($path, $contents, $options = [])
? $this->driver->writeStream($path, $contents, $options)
: $this->driver->write($path, $contents, $options);
} catch (UnableToWriteFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand Down Expand Up @@ -411,9 +407,7 @@ public function setVisibility($path, $visibility)
try {
$this->driver->setVisibility($path, $this->parseVisibility($visibility));
} catch (UnableToSetVisibility $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand Down Expand Up @@ -471,9 +465,7 @@ public function delete($paths)
try {
$this->driver->delete($path);
} catch (UnableToDeleteFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

$success = false;
}
Expand All @@ -494,9 +486,7 @@ public function copy($from, $to)
try {
$this->driver->copy($from, $to);
} catch (UnableToCopyFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand All @@ -516,9 +506,7 @@ public function move($from, $to)
try {
$this->driver->move($from, $to);
} catch (UnableToMoveFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand Down Expand Up @@ -567,9 +555,7 @@ public function readStream($path)
try {
return $this->driver->readStream($path);
} catch (UnableToReadFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);
}
}

Expand All @@ -581,9 +567,7 @@ public function writeStream($path, $resource, array $options = [])
try {
$this->driver->writeStream($path, $resource, $options);
} catch (UnableToWriteFile $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand Down Expand Up @@ -781,9 +765,7 @@ public function makeDirectory($path)
try {
$this->driver->createDirectory($path);
} catch (UnableToCreateDirectory $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand All @@ -802,9 +784,7 @@ public function deleteDirectory($directory)
try {
$this->driver->deleteDirectory($directory);
} catch (UnableToDeleteDirectory $e) {
if ($this->throwsExceptions()) {
throw $e;
}
throw_if($this->throwsExceptions(), $e);

return false;
}
Expand Down Expand Up @@ -881,7 +861,7 @@ public function buildTemporaryUrlsUsing(Closure $callback)
*/
protected function throwsExceptions(): bool
{
return (bool) ($this->config['throws_exceptions'] ?? false);
return (bool) ($this->config['throw'] ?? false);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public function testTemporaryUrlWithCustomCallback()

public function testThrowExceptionForGet()
{
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throws_exceptions' => true]);
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);

try {
$adapter->get('/foo.txt');
Expand All @@ -413,7 +413,7 @@ public function testThrowExceptionForGet()

public function testThrowExceptionsForReadStream()
{
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throws_exceptions' => true]);
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);

try {
$adapter->readStream('/foo.txt');
Expand All @@ -431,7 +431,7 @@ public function testThrowExceptionsForPut()
{
mkdir(__DIR__.'/tmp/bar', 0600);

$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throws_exceptions' => true]);
$adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);

try {
$adapter->put('/bar/foo.txt', 'Hello World!');
Expand Down

0 comments on commit 1e11a68

Please sign in to comment.