You are here

function realistic_dummy_content_api_rand in Realistic Dummy Content 7.2

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 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_API_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 Framework::instance()->sequential().

See the documentation for Math::sequential() for details.

Parameters

int $start: The first possible number in the range.

int $end: The last possible number in the range.

string $hash: (Default is NULL). Ignored for random numbers; for sequential numbers, please see the documentation for Math::sequential() for details.

Return value

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

1 call to realistic_dummy_content_api_rand()
RealisticDummyContentFieldModifier::rand in api/src/includes/RealisticDummyContentFieldModifier.php
Generate a random number, or during tests, give the first available number.
2 string references to 'realistic_dummy_content_api_rand'
RealisticDummyContentDatabaseTestCase::setUp in api/drupal7-simpletests/RealisticDummyContentDatabaseTestCase.test
Enable the module
realistic_dummy_content_api_uninstall in api/realistic_dummy_content_api.install
Implements hook_uninstall().

File

api/realistic_dummy_content_api.module, line 355
API code allowing other modules to generate realistic dummy content.

Code

function realistic_dummy_content_api_rand($start, $end, $hash = NULL) {
  if (Framework::instance()
    ->configGet('realistic_dummy_content_api_rand', REALISTIC_DUMMY_CONTENT_API_RANDOM)) {
    return rand($start, $end);
  }
  else {
    $math = new Math();
    return $math
      ->sequential($start, $end, $hash);
  }
}