You are here

public function Random::string in Schema.org Metatag 7

Return a random string of a given length.

1 call to Random::string()
Random::name in src/SchemaMetatagManager.php
Return a random string of a given length.

File

src/SchemaMetatagManager.php, line 23
A generic substitution for Drupal 8 Random utility.

Class

Random
A class to create random strings for testing.

Code

public function string($length, $other) {
  $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  $randstring = '';
  for ($i = 0; $i < $length; $i++) {
    $randstring .= $characters[rand(0, strlen($characters) - 1)];
  }
  return $randstring;
}