composer package updates
[openemr.git] / vendor / stripe / stripe-php / lib / Util / RandomGenerator.php
blob470f2bce8b32938678939dcd861a83335805683d
1 <?php
3 namespace Stripe\Util;
5 /**
6 * A basic random generator. This is in a separate class so we the generator
7 * can be injected as a dependency and replaced with a mock in tests.
8 */
9 class RandomGenerator
11 /**
12 * Returns a random value between 0 and $max.
14 * @param float $max (optional)
15 * @return float
17 public function randFloat($max = 1.0)
19 return mt_rand() / mt_getrandmax() * $max;
22 /**
23 * Returns a v4 UUID.
25 * @return string
27 public function uuid()
29 $arr = array_values(unpack('N1a/n4b/N1c', openssl_random_pseudo_bytes(16)));
30 $arr[2] = ($arr[2] & 0x0fff) | 0x4000;
31 $arr[3] = ($arr[3] & 0x3fff) | 0x8000;
32 return vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);