PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php +9 -11 1.2.131.4.1 View file →
@@ -9,13 +9,13 @@
9 9 * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
10 10 * @license http://opensource.org/licenses/MIT MIT
11 11 */
12 12 declare (strict_types=1);
13 -namespace Dudlewebs\WPMCS\Ramsey\Uuid\Provider\Node;
13 +namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Provider\Node;
14 14
15 -use Dudlewebs\WPMCS\Ramsey\Uuid\Exception\RandomSourceException;
16 -use Dudlewebs\WPMCS\Ramsey\Uuid\Provider\NodeProviderInterface;
17 -use Dudlewebs\WPMCS\Ramsey\Uuid\Type\Hexadecimal;
15 +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Exception\RandomSourceException;
16 +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Provider\NodeProviderInterface;
17 +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Type\Hexadecimal;
18 18 use Throwable;
19 19 use function bin2hex;
20 20 use function dechex;
21 21 use function hex2bin;
@@ -25,16 +25,16 @@
25 25 use const STR_PAD_LEFT;
26 26 /**
27 27 * RandomNodeProvider generates a random node ID
28 28 *
29 - * @link http://tools.ietf.org/html/rfc4122#section-4.5 RFC 4122, ยง 4.5: Node IDs that Do Not Identify the Host
29 + * @link https://www.rfc-editor.org/rfc/rfc9562#section-6.10 RFC 9562, 6.10. UUIDs That Do Not Identify the Host
30 30 */
31 31 class RandomNodeProvider implements NodeProviderInterface
32 32 {
33 - public function getNode(): Hexadecimal
33 + public function getNode() : Hexadecimal
34 34 {
35 35 try {
36 - $nodeBytes = random_bytes(6);
36 + $nodeBytes = \random_bytes(6);
37 37 } catch (Throwable $exception) {
38 38 throw new RandomSourceException($exception->getMessage(), (int) $exception->getCode(), $exception);
39 39 }
40 40 // Split the node bytes for math on 32-bit systems.
@@ -39,11 +39,9 @@
39 39 }
40 40 // Split the node bytes for math on 32-bit systems.
41 41 $nodeMsb = substr($nodeBytes, 0, 3);
42 42 $nodeLsb = substr($nodeBytes, 3);
43 - // Set the multicast bit; see RFC 4122, section 4.5.
43 + // Set the multicast bit; see RFC 9562, section 6.10.
44 44 $nodeMsb = hex2bin(str_pad(dechex(hexdec(bin2hex($nodeMsb)) | 0x10000), 6, '0', STR_PAD_LEFT));
45 - // Recombine the node bytes.
46 - $node = $nodeMsb . $nodeLsb;
47 - return new Hexadecimal(str_pad(bin2hex($node), 12, '0', STR_PAD_LEFT));
45 + return new Hexadecimal(str_pad(bin2hex($nodeMsb . $nodeLsb), 12, '0', STR_PAD_LEFT));
48 46 }
49 47 }