You are here

static function Util::randomProtocol in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/Util.php \Drupal\xautoload\Util::randomProtocol()

Generate a random string that is a stream wrapper protocol.

Parameters

int $length: Length of the random string to generate

Return value

string Random string of the specified length

File

src/Util.php, line 73

Class

Util
A number of static methods that don't interact with any global state.

Namespace

Drupal\xautoload

Code

static function randomProtocol($length = 40) {

  // Since PHP is case insensitive, we only user lowercase characters.
  $chars_first = 'abcdefghijklmnopqrstuvwxyz_';
  $chars = 'abcdefghijklmnopqrstuvwxyz_1234567890';
  return self::randomString($length, $chars, $chars_first);
}