You are here

function cf_is_empty_or_non_string in Common Functionality 7.2

Same name and namespace in other branches
  1. 7 cf.module \cf_is_empty_or_non_string()

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

Justification: Checking that a string is empty may also require a check to see if a variable is a string. 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

18 calls to cf_is_empty_or_non_string()
cf_db_options_create_options_relation in modules/cf_db_options/cf_db_options.module
Creates a table for many-one relations with an option table.
cf_db_options_get_options in modules/cf_db_options/cf_db_options.module
Get an array of supported options for a given option type.
cf_db_options_get_options_list in modules/cf_db_options/cf_db_options.module
Returns a list of options.
cf_db_options_get_options_name in modules/cf_db_options/cf_db_options.module
Builds an options table name.
cf_db_options_machine_name_to_id in modules/cf_db_options/cf_db_options.module
Returns the numeric id for a given option machine_name.

... See full list

File

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

Code

function cf_is_empty_or_non_string($argument_name, $variable, $severity = WATCHDOG_WARNING) {
  if ($argument_name == '') {
    if (class_exists('cf_error')) {
      cf_error::empty_string('argument_name');
    }
  }
  if (!is_string($variable)) {
    if (class_exists('cf_error')) {
      cf_error::invalid_string($argument_name, $severity);
    }
    return TRUE;
  }
  if ($variable == '') {
    if (class_exists('cf_error')) {
      cf_error::empty_string($argument_name, $severity);
    }
    return TRUE;
  }
  return FALSE;
}