modifs.mineures sans commentaires
This commit is contained in:
parent
ba4a67658f
commit
a7bcfe9ce6
|
@ -9,22 +9,22 @@ use nur\A;
|
|||
*/
|
||||
class ValueException extends UserException {
|
||||
/** Retourner $value si elle n'est pas false. sinon lancer une exception */
|
||||
static final function check_nf($value, $message=null) {
|
||||
if ($value !== false) return $value;
|
||||
static final function check_nf($value, $message=null, bool $required=true) {
|
||||
if ($value !== false || !$required) return $value;
|
||||
if ($message === null) $message = "value must not be false";
|
||||
throw new self($message);
|
||||
}
|
||||
|
||||
/** Retourner $value si elle n'est pas null. sinon lancer une exception */
|
||||
static final function check_nn($value, $message=null) {
|
||||
if ($value !== null) return $value;
|
||||
static final function check_nn($value, $message=null, bool $required=true) {
|
||||
if ($value !== null || !$required) return $value;
|
||||
if ($message === null) $message = "value must not be null";
|
||||
throw new self($message);
|
||||
}
|
||||
|
||||
/** Retourner $value si elle n'est ni null ni false. sinon lancer une exception */
|
||||
static final function check_nz($value, $message=null) {
|
||||
if ($value !== false && $value !== null) return $value;
|
||||
static final function check_nz($value, $message=null, bool $required=true) {
|
||||
if (($value !== false && $value !== null) || !$required) return $value;
|
||||
if ($message === null) $message = "value must not be false nor null";
|
||||
throw new ValueException($message);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue