PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.2
GiveWP – Donation Plugin and Fundraising Platform v4.15.2
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / vendor / stripe / stripe-php / lib / Util / RandomGenerator.php

RandomGenerator.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.2, at vendor/stripe/stripe-php/lib/Util/RandomGenerator.php

37 lines 814 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Stripe\Util;
4
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
10 {
11 /**
12 * Returns a random value between 0 and $max.
13 *
14 * @param float $max (optional)
15 *
16 * @return float
17 */
18 public function randFloat($max = 1.0)
19 {
20 return \mt_rand() / \mt_getrandmax() * $max;
21 }
22
23 /**
24 * Returns a v4 UUID.
25 *
26 * @return string
27 */
28 public function uuid()
29 {
30 $arr = \array_values(\unpack('N1a/n4b/N1c', \openssl_random_pseudo_bytes(16)));
31 $arr[2] = ($arr[2] & 0x0FFF) | 0x4000;
32 $arr[3] = ($arr[3] & 0x3FFF) | 0x8000;
33
34 return \vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
35 }
36 }
37