X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcriteria%2Fclass_BaseCriteria.php;h=b53ce6482845616efafdb17cc0fe32f9d7ff6580;hp=3b97b8b5f432d1b4fad74e23e9151d54671bf66b;hb=6b2a7074aee52128919afc159f1df3ba8f1a5515;hpb=aaf61bc15598811622c2aa1ef42d5428c0711fac diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php index 3b97b8b5..b53ce648 100644 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ b/inc/classes/main/criteria/class_BaseCriteria.php @@ -50,6 +50,43 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { parent::__construct($className); } + /** + * Checks whether given key is set + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isKeySet ($criteriaType, $criteriaKey) { + // Determine it + $isSet = isset($this->criteria[$criteriaType][$criteriaKey]); + + // Return it + return $isSet; + } + + /** + * Checks whether given key is set for 'choice' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isChoiceKeySet ($criteriaKey) { + // Call inner method + return $this->isKeySet('choice', $criteriaKey); + } + + /** + * Checks whether given key is set for 'exclude' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isExcludeKeySet ($criteriaKey) { + // Call inner method + return $this->isKeySet('exclude', $criteriaKey); + } + /** * Setter for wrapper class name * @@ -115,7 +152,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); // Is it already there? - if (isset($this->criteria[$criteriaType][$criteriaKey])) { + if ($this->isKeySet($criteriaType, $criteriaKey)) { // Append it $this->criteria[$criteriaType][$criteriaKey] .= ',' . $criteriaValue; } else { @@ -186,7 +223,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { $value = NULL; // Is the criteria there? - if (isset($this->criteria[$criteriaType][$criteriaKey])) { + if ($this->isKeySet($criteriaType, $criteriaKey)) { // Then use it $value = $this->criteria[$criteriaType][$criteriaKey]; } // END - if