nur-sery/src/StateException.php

24 lines
682 B
PHP
Raw Normal View History

2024-04-05 08:31:49 +04:00
<?php
namespace nur\sery;
use LogicException;
/**
* Class StateException: indiquer que l'état dans lequel on se trouve est
* inattendu: il s'agit donc d'un bug
*/
class StateException extends LogicException {
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);
}
}