<?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);
  }
}
