Initial Commit

This commit is contained in:
David Stone
2024-11-30 18:24:12 -07:00
commit e8f7955c1c
5432 changed files with 1397750 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
namespace WP_Ultimo\Dependencies\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] & 0xfff | 0x4000;
$arr[3] = $arr[3] & 0x3fff | 0x8000;
return \vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
}
}