mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Exception - 3 exceptions related to file path & content
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
31
src/Meritoo/Common/Exception/File/EmptyFileException.php
Normal file
31
src/Meritoo/Common/Exception/File/EmptyFileException.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/Meritoo/Common/Exception/File/EmptyFilePathException.php
Normal file
26
src/Meritoo/Common/Exception/File/EmptyFilePathException.php
Normal 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?');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user