diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/stripe/stripe-php/lib/Util/RandomGenerator.php | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
-rw-r--r-- | vendor/stripe/stripe-php/lib/Util/RandomGenerator.php | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/vendor/stripe/stripe-php/lib/Util/RandomGenerator.php b/vendor/stripe/stripe-php/lib/Util/RandomGenerator.php index b11e445..78a324e 100644 --- a/vendor/stripe/stripe-php/lib/Util/RandomGenerator.php +++ b/vendor/stripe/stripe-php/lib/Util/RandomGenerator.php @@ -1,36 +1,36 @@ -<?php - -namespace Stripe\Util; - -/** - * A basic random generator. This is in a separate class so we the generator - * can be injected as a dependency and replaced with a mock in tests. - */ -class RandomGenerator -{ - /** - * Returns a random value between 0 and $max. - * - * @param float $max (optional) - * - * @return float - */ - public function randFloat($max = 1.0) - { - return \mt_rand() / \mt_getrandmax() * $max; - } - - /** - * Returns a v4 UUID. - * - * @return string - */ - public function uuid() - { - $arr = \array_values(\unpack('N1a/n4b/N1c', \openssl_random_pseudo_bytes(16))); - $arr[2] = ($arr[2] & 0x0fff) | 0x4000; - $arr[3] = ($arr[3] & 0x3fff) | 0x8000; - - return \vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr); - } -} +<?php
+
+namespace Stripe\Util;
+
+/**
+ * A basic random generator. This is in a separate class so we the generator
+ * can be injected as a dependency and replaced with a mock in tests.
+ */
+class RandomGenerator
+{
+ /**
+ * Returns a random value between 0 and $max.
+ *
+ * @param float $max (optional)
+ *
+ * @return float
+ */
+ public function randFloat($max = 1.0)
+ {
+ return \mt_rand() / \mt_getrandmax() * $max;
+ }
+
+ /**
+ * Returns a v4 UUID.
+ *
+ * @return string
+ */
+ public function uuid()
+ {
+ $arr = \array_values(\unpack('N1a/n4b/N1c', \openssl_random_pseudo_bytes(16)));
+ $arr[2] = ($arr[2] & 0x0FFF) | 0x4000;
+ $arr[3] = ($arr[3] & 0x3FFF) | 0x8000;
+
+ return \vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
+ }
+}
|