From ba3b35de9b7e9f47d0952978f29ede3e0021a1ca Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 7 Feb 2025 22:24:57 -0500 Subject: [PATCH] Added parameter nullAllowed to return True if the parameter exists AND the parameter is not null if nullAllowed is set to False, by default it's True. --- src/Socialbox/Objects/RpcRequest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Socialbox/Objects/RpcRequest.php b/src/Socialbox/Objects/RpcRequest.php index 1efe1d8..7751907 100644 --- a/src/Socialbox/Objects/RpcRequest.php +++ b/src/Socialbox/Objects/RpcRequest.php @@ -68,10 +68,16 @@ * Checks if the parameter exists within the RPC request * * @param string $parameter The parameter to check + * @param bool $nullAllowed True if the parameter value can be null, False otherwise. * @return bool True if the parameter exists, False otherwise. */ - public function containsParameter(string $parameter): bool + public function containsParameter(string $parameter, bool $nullAllowed=true): bool { + if(!$nullAllowed) + { + return isset($this->parameters[$parameter]) && $this->parameters[$parameter] !== null; + } + return isset($this->parameters[$parameter]); }