nur-sery/nur_src/b/IllegalAccessException.php

29 lines
937 B
PHP
Raw Normal View History

2023-12-03 22:10:18 +04:00
<?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);
}
}