You are here

class Random in Schema.org Metatag 7

A class to create random strings for testing.

Hierarchy

Expanded class hierarchy of Random

File

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

View source
class Random {

  /**
   * Return a random string of a given length.
   */
  public function name($length, $other) {
    return $this
      ->string($length, $other);
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
Random::name public function Return a random string of a given length.
Random::string public function Return a random string of a given length.