From 9730c4e798e50c337fe5ecdb3933409f2c86b8c8 Mon Sep 17 00:00:00 2001 From: David Maus <maus@hab.de> Date: Mon, 13 May 2013 15:00:38 +0200 Subject: [PATCH] New function: Return true if bag contains a parameter-value-pair * VuFindSearch/ParamBag.php (contains): New function. Return true if bag contains a parameter-value-pair. --- module/VuFindSearch/src/VuFindSearch/ParamBag.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/module/VuFindSearch/src/VuFindSearch/ParamBag.php b/module/VuFindSearch/src/VuFindSearch/ParamBag.php index edca2dd1d57..6a414af485a 100644 --- a/module/VuFindSearch/src/VuFindSearch/ParamBag.php +++ b/module/VuFindSearch/src/VuFindSearch/ParamBag.php @@ -77,6 +77,20 @@ class ParamBag return isset($this->params[$name]) ? $this->params[$name] : null; } + /** + * Return true if the bag contains a parameter-value-pair. + * + * @param string $name Parameter name + * @param string $value Parameter value + * + * @return boolean + */ + public function contains($name, $value) + { + $haystack = $this->get($name); + return is_array($haystack) && in_array($value, $haystack); + } + /** * Set a parameter. * -- GitLab