You are here

function cf_is_empty_or_non_array in Common Functionality 7.2

Checks if a variable is an empty array is empty or not an array at all.

Justification: Checking that an array is empty may also require a check to see if a variable is an array. This provides a way to do that two step process in 1 step. Do not use this for any other purpose.

Parameters

string $argument_name: The variable name of the argument in question.

$variable: The argument that is to be validated.

int $severity: (optional) This is passed directly to watchdog and represents the severity of the report.

Return value

bool When the check passed returns TRUE, FALSE otherwise.

Related topics

1 call to cf_is_empty_or_non_array()
cf_db_options_add_options in modules/cf_db_options/cf_db_options.module
Populate a specific options table.

File

./cf.module, line 332
Common Functionality module.

Code

function cf_is_empty_or_non_array($argument_name, $variable, $severity = WATCHDOG_WARNING) {
  if ($argument_name == '') {
    if (class_exists('cf_error')) {
      cf_error::empty_string('argument_name');
    }
  }
  if (!is_array($variable)) {
    if (class_exists('cf_error')) {
      cf_error::invalid_array($argument_name, $severity);
    }
    return TRUE;
  }
  if (empty($variable)) {
    if (class_exists('cf_error')) {
      cf_error::empty_array($argument_name, $severity);
    }
    return TRUE;
  }
  return FALSE;
}