<?php
namespace nur\b;

/**
 * Class IllegalAccessException: exception lancée quand un objet est utilisée
 * d'une manière illégale: opération interdite, méthode non implémentée, etc.
 */
class IllegalAccessException extends UserException {
  static final function immutable_object(?string $dest=null): self {
    if ($dest === null) $dest = "this object";
    return new static("$dest is immutable");
  }

  static final function not_allowed(?string $action=null): self {
    if ($action === null) $action = "this operation";
    return new static("$action is not allowed");
  }

  static final function not_implemented(?string $method=null): self {
    if ($method === null) $method = "this method";
    return new static("$method is not implemented");
  }

  static final function unexpected_state(?string $message=null): self {
    if ($message === null) $message = "unexpected state";
    return new static($message);
  }
}