You are here

protected function TestController::randGen in Dropdown Attributes 8

Generate a random string.

Parameters

int $length: Length of string to return.

Return value

string Random string.

6 calls to TestController::randGen()
TestController::createAttribute in uc_dropdown_test/src/Controller/TestController.php
Creates an attribute.
TestController::createAttributeOption in uc_dropdown_test/src/Controller/TestController.php
Creates an attribute option.
TestController::createProduct in uc_dropdown_test/src/Controller/TestController.php
Create a product.
TestController::createProductKit in uc_dropdown_test/src/Controller/TestController.php
Create a product kit.
TestController::productClass in uc_dropdown_test/src/Controller/TestController.php

... See full list

File

uc_dropdown_test/src/Controller/TestController.php, line 524

Class

TestController
Additional test of Dropdown Attributes UI.

Namespace

Drupal\uc_dropdown_test\Controller

Code

protected function randGen($length) {
  $i = 0;
  $result = "";
  while ($i <= $length) {
    $num = rand() % strlen($this->vals);
    $tmp = substr($this->vals, $num, 1);
    $result = $result . $tmp;
    $i++;
  }
  return $result;
}