24 lines
669 B
PHP
24 lines
669 B
PHP
<?php
|
|
namespace nulib;
|
|
|
|
use Exception;
|
|
|
|
/**
|
|
* Class StateException: indiquer que l'état dans lequel on se trouve est
|
|
* inattendu: il s'agit donc d'un bug
|
|
*/
|
|
class StateException extends Exception {
|
|
static final function not_implemented(?string $method=null, ?string $prefix=null): self {
|
|
if ($method === null) $method = "this method";
|
|
$message = "$method is not implemented";
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function unexpected_state(?string $prefix=null): self {
|
|
$message = "unexpected state";
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
return new static($prefix.$message);
|
|
}
|
|
}
|