2023-10-03 04:17:01 +04:00
|
|
|
<?php
|
2023-10-20 09:59:43 +04:00
|
|
|
namespace nulib;
|
2023-10-03 04:17:01 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|