diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 043f11e4d1de..783ef3dc3a40 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -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); } } @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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); } } @@ -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; } @@ -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; } @@ -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; } @@ -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); } /** diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index 2d5ca5941241..f125edbe74ba 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -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'); @@ -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'); @@ -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!');