37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
namespace nur\sery;
|
|
|
|
/**
|
|
* Class AccessException: indiquer que la resource ou l'objet auquel on veut
|
|
* accéder n'est pas accessible. il s'agit donc d'une erreur de l'utilisateur
|
|
*/
|
|
class AccessException extends UserException {
|
|
static final function read_only(?string $dest=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($dest === null) $dest = "this property";
|
|
$message = "$dest is read-only";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function immutable_object(?string $dest=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($dest === null) $dest = "this object";
|
|
$message = "$dest is immutable";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function not_allowed(?string $action=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($action === null) $action = "this operation";
|
|
$message = "$action is not allowed";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function not_accessible(?string $dest=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($dest === null) $dest = "this resource";
|
|
$message = "$dest is not accessible";
|
|
return new static($prefix.$message);
|
|
}
|
|
}
|