Exception - 3 exceptions related to file path & content

This commit is contained in:
Meritoo
2017-09-20 13:50:18 +02:00
parent 284d403061
commit 0b560fdf18
4 changed files with 89 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
"name": "meritoo/common-library", "name": "meritoo/common-library",
"description": "Useful classes, methods, extensions etc.", "description": "Useful classes, methods, extensions etc.",
"license": "MIT", "license": "MIT",
"version": "0.0.8", "version": "0.0.9",
"authors": [ "authors": [
{ {
"name": "Meritoo.pl", "name": "Meritoo.pl",

View File

@@ -0,0 +1,31 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Exception\File;
/**
* An exception used while file with given path is empty (has no content)
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @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);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Exception\File;
/**
* An exception used while path of given file is empty
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @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?');
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Meritoo\Common\Exception\File;
/**
* An exception used while file with given path does not exist
*
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
* @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);
}
}