Add classes and tests from common project

This commit is contained in:
2024-06-03 19:46:39 -04:00
parent e91acee70f
commit 1164dc7cc5
32 changed files with 3175 additions and 0 deletions

30
src/DocumentException.php Normal file
View File

@@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace BitBadger\PDODocument;
use Exception;
use Throwable;
/**
* Exceptions occurring during document processing
*/
class DocumentException extends Exception
{
/**
* Constructor
*
* @param string $message A message for the exception
* @param int $code The code for the exception (optional; defaults to 0)
* @param Throwable|null $previous The previous exception (optional; defaults to `null`)
*/
public function __construct(string $message, int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function __toString(): string
{
$codeStr = $this->code == 0 ? '' : "[$this->code] ";
return __CLASS__ . ": $codeStr$this->message\n";
}
}