Exceptions > create instance of exception using static "create()" method (instead of constructor)

This commit is contained in:
Meritoo
2018-07-02 08:52:01 +02:00
parent 9342f0e87e
commit 834b24f348
35 changed files with 139 additions and 105 deletions

View File

@@ -17,15 +17,16 @@ namespace Meritoo\Common\Exception\File;
class EmptyFileException extends \Exception
{
/**
* Class constructor
* Creates exception
*
* @param string $emptyFilePath Path of the empty file
* @return EmptyFileException
*/
public function __construct($emptyFilePath)
public static function create($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);
return new static($message);
}
}