From 0b560fdf181f6a669894ee8eb358d3206e065674 Mon Sep 17 00:00:00 2001 From: Meritoo Date: Wed, 20 Sep 2017 13:50:18 +0200 Subject: [PATCH] Exception - 3 exceptions related to file path & content --- composer.json | 2 +- .../Exception/File/EmptyFileException.php | 31 +++++++++++++++++++ .../Exception/File/EmptyFilePathException.php | 26 ++++++++++++++++ .../File/NotExistingFileException.php | 31 +++++++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/Meritoo/Common/Exception/File/EmptyFileException.php create mode 100644 src/Meritoo/Common/Exception/File/EmptyFilePathException.php create mode 100644 src/Meritoo/Common/Exception/File/NotExistingFileException.php diff --git a/composer.json b/composer.json index 5994ae7..f3c18d6 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "meritoo/common-library", "description": "Useful classes, methods, extensions etc.", "license": "MIT", - "version": "0.0.8", + "version": "0.0.9", "authors": [ { "name": "Meritoo.pl", diff --git a/src/Meritoo/Common/Exception/File/EmptyFileException.php b/src/Meritoo/Common/Exception/File/EmptyFileException.php new file mode 100644 index 0000000..14734d7 --- /dev/null +++ b/src/Meritoo/Common/Exception/File/EmptyFileException.php @@ -0,0 +1,31 @@ + + * @copyright Meritoo.pl + */ +class EmptyFileException extends \Exception +{ + /** + * Class constructor + * + * @param string $emptyFilePath Path of the empty file + */ + public function __construct($emptyFilePath) + { + $template = 'File with path \'%s\' is empty (has no content). Did you provide path of proper file?'; + $message = sprintf($template, $emptyFilePath); + + parent::__construct($message); + } +} diff --git a/src/Meritoo/Common/Exception/File/EmptyFilePathException.php b/src/Meritoo/Common/Exception/File/EmptyFilePathException.php new file mode 100644 index 0000000..5f80e6b --- /dev/null +++ b/src/Meritoo/Common/Exception/File/EmptyFilePathException.php @@ -0,0 +1,26 @@ + + * @copyright Meritoo.pl + */ +class EmptyFilePathException extends \Exception +{ + /** + * Class constructor + */ + public function __construct() + { + parent::__construct('Path of the file is empty. Did you provide path of proper file?'); + } +} diff --git a/src/Meritoo/Common/Exception/File/NotExistingFileException.php b/src/Meritoo/Common/Exception/File/NotExistingFileException.php new file mode 100644 index 0000000..d870881 --- /dev/null +++ b/src/Meritoo/Common/Exception/File/NotExistingFileException.php @@ -0,0 +1,31 @@ + + * @copyright Meritoo.pl + */ +class NotExistingFileException extends \Exception +{ + /** + * Class constructor + * + * @param string $notExistingFilePath Path of not existing (or not readable) file + */ + public function __construct($notExistingFilePath) + { + $template = 'File with path \'%s\' does not exist (or is not readable). Did you provide proper path of file?'; + $message = sprintf($template, $notExistingFilePath); + + parent::__construct($message); + } +}