Debian Codegraph @

vendor/ramsey/uuid/src/BinaryUtils.php

raw
1 <?php
2
3 namespace Ramsey\Uuid;
4
5 /**
6 * Provides binary math utilities
7 */
8 class BinaryUtils
9 {
10 /**
11 * Applies the RFC 4122 variant field to the `clock_seq_hi_and_reserved` field
12 *
13 * @param $clockSeqHi
14 * @return int The high field of the clock sequence multiplexed with the variant
15 * @link http://tools.ietf.org/html/rfc4122#section-4.1.1
16 */
17 public static function applyVariant($clockSeqHi)
18 {
19 // Set the variant to RFC 4122
20 $clockSeqHi = $clockSeqHi & 0x3f;
21 $clockSeqHi |= 0x80;
22
23 return $clockSeqHi;
24 }
25
26 /**
27 * Applies the RFC 4122 version number to the `time_hi_and_version` field
28 *
29 * @param string $timeHi
30 * @param integer $version
31 * @return int The high field of the timestamp multiplexed with the version number
32 * @link http://tools.ietf.org/html/rfc4122#section-4.1.3
33 */
34 public static function applyVersion($timeHi, $version)
35 {
36 $timeHi = hexdec($timeHi) & 0x0fff;
37 $timeHi |= $version << 12;
38
39 return $timeHi;
40 }
41 }