}
/**
- * Determines if a key is set in the generic array
+ * Determines if an element is set in the generic array
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $key Key to check
+ * @param $element Element to check
* @return $isset Whether the given key is set
*/
- protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+ protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
// Is it there?
- $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
+ $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
// Return it
return $isset;
}
-
/**
- * Determines if an element is set in the generic array
+ * Determines if a key is set in the generic array
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $key Key to check
- * @param $element Element to check
* @return $isset Whether the given key is set
*/
- protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+ protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
// Is it there?
- $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+ $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
// Return it
return $isset;
}
+
/**
* Determines if a group is set in the generic array
*
} // END - if
// Return it
+ //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' returning!' . PHP_EOL);
return $this->genericArray[$keyGroup][$subGroup];
}
* @param $key Key to unset
* @return void
*/
- protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key) {
+ protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
// Remove it
+ //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL);
unset($this->genericArray[$keyGroup][$subGroup][$key]);
}
+ /**
+ * Unsets a given element in generic array
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @param $element Element to unset
+ * @return void
+ */
+ protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+ // Remove it
+ //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL);
+ unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+ }
+
/**
* Append a string to a given generic array key
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $key Key to use
+ * @param $forceInit Optionally force initialization
* @return void
*/
- protected final function initGenericArray ($keyGroup, $subGroup, $key) {
+ protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
// Is it already set?
- if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
// Already initialized
trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
} // END - if
// Initialize it
+ //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . PHP_EOL);
$this->genericArray[$keyGroup][$subGroup][$key] = array();
}
// Is it set?
if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Initialize array
- $this->initGenericArray($keyGroup, $subGroup, $key);
+ $this->initGenericArrayKey($keyGroup, $subGroup, $key);
} // END - if
// Then push it
- //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value=' . $value . PHP_EOL);
+ //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
$count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
// Return count
// Return value
//* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
- //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . $value . PHP_EOL);
+ //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
return $value;
}
// Return it
return $isValid;
}
+
+ /**
+ * Checks if a given key is valid (array)
+ *
+ * @param $keyGroup Key group to get
+ * @param $subGroup Sub group for the key
+ * @param $key Key to check
+ * @return $isValid Whether given sub group is valid
+ */
+ protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
+ // Determine it
+ $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
+
+ // Return it
+ return $isValid;
+ }
}
// [EOF]