From 1dca3e8bee4ed21c8d8ce45978cb5c9c5cbb22ac Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 15 Nov 2024 15:56:38 +0400 Subject: [PATCH] ajout check_null --- src/ValueException.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ValueException.php b/src/ValueException.php index d823e72..5f0ec3a 100644 --- a/src/ValueException.php +++ b/src/ValueException.php @@ -44,6 +44,10 @@ class ValueException extends UserException { return new static(self::message(null, $message, $kind, $prefix, " should not be null")); } + static final function check_null($value, ?string $kind=null, ?string $prefix=null, ?string $message=null): void { + if ($value === null) throw static::null($kind, $prefix, $message); + } + static final function invalid_kind($value=null, ?string $kind=null, ?string $prefix=null, ?string $message=null): self { return new static(self::message($value, $message, $kind, $prefix, " is invalid")); }