Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RandomBytesGenerator.php

function RandomBytesGenerator::generate

@inheritDoc

Throws

RandomSourceException if random_bytes() throws an exception/error

Overrides RandomGeneratorInterface::generate

File

vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php, line 33

Class

RandomBytesGenerator
RandomBytesGenerator generates strings of random binary data using the built-in `random_bytes()` PHP function

Namespace

Ramsey\Uuid\Generator

Code

public function generate(int $length) : string {
    try {
        return random_bytes($length);
    } catch (Throwable $exception) {
        throw new RandomSourceException($exception->getMessage(), (int) $exception->getCode(), $exception);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal