You are here

function realistic_dummy_content_api_rand in Realistic Dummy Content 7

Same name and namespace in other branches
  1. 8.2 api/realistic_dummy_content_api.module \realistic_dummy_content_api_rand()
  2. 8 api/realistic_dummy_content_api.module \realistic_dummy_content_api_rand()
  3. 7.2 api/realistic_dummy_content_api.module \realistic_dummy_content_api_rand()
  4. 3.x api/realistic_dummy_content_api.module \realistic_dummy_content_api_rand()

Generate a random, or sequential, number

By default, this function will return a random number between $start and $end inclusively. If you set the realistic_dummy_content_api_rand variable to REALISTIC_DUMMY_CONTENT_SEQUENTIAL, for example for automated tested or in a recipe (an example can be found at realistic_dummy_content/recipe/realistic_dummy_content.recipe.inc), then this will call realistic_dummy_content_api_sequential().

See the documentation for realistic_dummy_content_api_sequential() for details.

Parameters

$start: The first possible number in the range.

$end: The last possible number in the range.

$hash = NULL: Ignored for random numbers; for sequential numbers, please se the documentation for realistic_dummy_content_api_sequential() for details.

Return value

A random number by default, or a sequential number if you set the realistic_dummy_content_api_rand variable to REALISTIC_DUMMY_CONTENT_SEQUENTIAL. Please see the description of realistic_dummy_content_api_sequential() for details.

1 call to realistic_dummy_content_api_rand()
RealisticDummyContentFieldModifier::rand in api/includes/RealisticDummyContentEntityFieldModifier.inc
Generate a random number, or during tests, give the first available number.
2 string references to 'realistic_dummy_content_api_rand'
realistic_dummy_content_api_uninstall in api/realistic_dummy_content_api.install
Implements hook_uninstall().
realistic_dummy_content_DatabaseTestCase::setUp in api/tests/realistic_dummy_content_api.db.test
Enable the module

File

api/realistic_dummy_content_api.module, line 325
API code allowing other modules to generate realistic dummy content. See the Realistic Dummy Content module for an example of how to use.

Code

function realistic_dummy_content_api_rand($start, $end, $hash = NULL) {
  if (variable_get('realistic_dummy_content_api_rand', REALISTIC_DUMMY_CONTENT_RANDOM)) {
    return rand($start, $end);
  }
  else {
    return realistic_dummy_content_api_sequential($start, $end, $hash);
  }
}