You are here

static function RealisticDummyContent::rand in Realistic Dummy Content 8

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 RealisticDummyContent::rand()
realistic_dummy_content_api_rand in api/realistic_dummy_content_api.module
Generate a random, or sequential, number

File

api/src/facade/RealisticDummyContent.php, line 209
Define autoload class.

Class

RealisticDummyContent

Namespace

Drupal\realistic_dummy_content_api\facade

Code

static function rand($start, $end, $hash = NULL) {
  if (\Drupal::state()
    ->get('realistic_dummy_content_api_rand') ?: RealisticDummyContent::REALISTIC_DUMMY_CONTENT_RANDOM) {
    return rand($start, $end);
  }
  else {
    return RealisticDummyContent::sequential($start, $end, $hash);
  }
}