ILIAS  release_8 Revision v8.24
ilRandom Class Reference

Wrapper for generation of random numbers, strings, bytes. More...

+ Collaboration diagram for ilRandom:

Public Member Functions

 int (int $min=0, int $max=PHP_INT_MAX)
 

Private Member Functions

 logIfPossible (callable $c)
 

Detailed Description

Wrapper for generation of random numbers, strings, bytes.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 10 of file class.ilRandom.php.

Member Function Documentation

◆ int()

ilRandom::int ( int  $min = 0,
int  $max = PHP_INT_MAX 
)

Definition at line 21 of file class.ilRandom.php.

21 : int
22 {
23 try {
24 return random_int($min, $max);
25 } catch (Throwable $e) {
26 $this->logIfPossible(static function (ilLogger $logger): void {
28 $logger->error('No suitable random number generator found.');
29 });
30 throw $e;
31 }
32 }
Component logger with individual log levels by component id.
error(string $a_message)
logStack(?int $a_level=null, string $a_message='')
logIfPossible(callable $c)

References Vendor\Package\$e, ilLogger\error(), ilLogLevel\ERROR, logIfPossible(), and ilLogger\logStack().

+ Here is the call graph for this function:

◆ logIfPossible()

ilRandom::logIfPossible ( callable  $c)
private

Definition at line 12 of file class.ilRandom.php.

12 : void
13 {
14 global $DIC;
15
16 if (isset($DIC['ilLoggerFactory'])) {
17 $c($DIC->logger()->rnd());
18 }
19 }
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28

References $c, and $DIC.

Referenced by int().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: