You are here

public function GetServices::generateReference in Simple Node Importer 8

Function to generate random strings.

Parameters

int $length: Number of characters in the generated string.

Return value

string A new string is created with random characters of the desired length.

File

src/Services/GetServices.php, line 803

Class

GetServices

Namespace

Drupal\simple_node_importer\Services

Code

public function generateReference(int $length = 10) {
  srand();
  $string = "";
  $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  for ($i = 0; $i < $length; $i++) {
    $string .= substr($chars, rand(0, strlen($chars)), 1);
  }
  return $string;
}