nulib/php/src_base/StateException.php

24 lines
679 B
PHP
Raw Normal View History

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
2023-12-28 19:33:05 +04:00
use LogicException;
2023-10-03 04:17:01 +04:00
/**
* Class StateException: indiquer que l'état dans lequel on se trouve est
* inattendu: il s'agit donc d'un bug
*/
2023-12-28 19:33:05 +04:00
class StateException extends LogicException {
2023-10-03 04:17:01 +04:00
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);
}
}