From 0ac8e7ff0f8651348599c2d5914c204b69ac53a1 Mon Sep 17 00:00:00 2001 From: Mathieu Dumoulin Date: Mon, 25 Jul 2016 11:58:14 -0400 Subject: [PATCH 1/2] Added AlreadyExistsExceptions for filesystem along with related exception tag --- .../DirectoryAlreadyExistsException.php | 22 +++++++++++++++++++ .../Filesystem/FileAlreadyExistsException.php | 22 +++++++++++++++++++ Exceptions/Tag/AlreadyExistsException.php | 15 +++++++++++++ Tests/ExceptionTest.php | 2 ++ 4 files changed, 61 insertions(+) create mode 100644 Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php create mode 100644 Exceptions/IO/Filesystem/FileAlreadyExistsException.php create mode 100644 Exceptions/Tag/AlreadyExistsException.php diff --git a/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php b/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php new file mode 100644 index 0000000..883e45e --- /dev/null +++ b/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php @@ -0,0 +1,22 @@ + + * @license MIT + */ +class DirectoryAlreadyExistsException extends FilesystemException implements AlreadyExistsException +{ + public function __construct( + $message = 'Cannot find specified directory', + $code = 0, + $previous = null + ) { + parent::__construct($message, $code, $previous); + } +} diff --git a/Exceptions/IO/Filesystem/FileAlreadyExistsException.php b/Exceptions/IO/Filesystem/FileAlreadyExistsException.php new file mode 100644 index 0000000..0792067 --- /dev/null +++ b/Exceptions/IO/Filesystem/FileAlreadyExistsException.php @@ -0,0 +1,22 @@ + + * @license MIT + */ +class FileAlreadyExistsException extends FilesystemException implements AlreadyExistsException +{ + public function __construct( + $message = 'Cannot find specified file', + $code = 0, + $previous = null + ) { + parent::__construct($message, $code, $previous); + } +} diff --git a/Exceptions/Tag/AlreadyExistsException.php b/Exceptions/Tag/AlreadyExistsException.php new file mode 100644 index 0000000..ac6cc4b --- /dev/null +++ b/Exceptions/Tag/AlreadyExistsException.php @@ -0,0 +1,15 @@ + + * @license MIT + */ +interface AlreadyExistsException +{ +} diff --git a/Tests/ExceptionTest.php b/Tests/ExceptionTest.php index a24336d..46fb053 100644 --- a/Tests/ExceptionTest.php +++ b/Tests/ExceptionTest.php @@ -34,10 +34,12 @@ public function providesConstructorTestClasses() [\Exceptions\Http\Server\NotImplementedException::class], [\Exceptions\Http\Server\ServiceUnavailableException::class], [\Exceptions\IO\Filesystem\FileNotWritableException::class], + [\Exceptions\IO\Filesystem\FileAlreadyExistsException::class], [\Exceptions\IO\Filesystem\NotAFileException::class], [\Exceptions\IO\Filesystem\NotADirectoryException::class], [\Exceptions\IO\Filesystem\FileNotFoundException::class], [\Exceptions\IO\Filesystem\DirectoryNotWritableException::class], + [\Exceptions\IO\Filesystem\DirectoryAlreadyExistsException::class], [\Exceptions\IO\Filesystem\DirectoryNotFoundException::class], [\Exceptions\IO\Filesystem\FileNotReadableException::class], [\Exceptions\IO\Filesystem\DirectoryNotReadableException::class], From 91989bd55de8742033f7254176c14201747c5283 Mon Sep 17 00:00:00 2001 From: Mathieu Dumoulin Date: Mon, 25 Jul 2016 13:33:18 -0400 Subject: [PATCH 2/2] Formatting fix --- Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php b/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php index 883e45e..9e99205 100644 --- a/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php +++ b/Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php @@ -5,7 +5,7 @@ use Exceptions\Tag\AlreadyExistsException; /** - * Use this exception when your code tries to create a local directory but it already exists + * Use this exception when your code tries to create a local directory but it already exists. * * @author Mathieu Dumoulin aka CrazyCodr * @license MIT