Debian Codegraph @

vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php

raw
1 <?php
2
3 /**
4 * This file is part of the ramsey/uuid library
5 *
6 * For the full copyright and license information, please view the LICENSE
7 * file that was distributed with this source code.
8 *
9 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10 * @license http://opensource.org/licenses/MIT MIT
11 */
12
13 declare(strict_types=1);
14
15 namespace Ramsey\Uuid\Converter;
16
17 use Ramsey\Uuid\Type\Hexadecimal;
18 use Ramsey\Uuid\Type\Time;
19
20 /**
21 * A time converter converts timestamps into representations that may be used in UUIDs
22 *
23 * @immutable
24 */
25 interface TimeConverterInterface
26 {
27 /**
28 * Uses the provided seconds and micro-seconds to calculate the count of 100-nanosecond intervals since
29 * UTC 00:00:00.00, 15 October 1582, for RFC 9562 (formerly RFC 4122) variant UUIDs
30 *
31 * @link https://www.rfc-editor.org/rfc/rfc9562#appendix-A RFC 9562, Appendix A. Test Vectors
32 *
33 * @param string $seconds A string representation of seconds since the Unix epoch for the time to calculate
34 * @param string $microseconds A string representation of the micro-seconds associated with the time to calculate
35 *
36 * @return Hexadecimal The full UUID timestamp as a Hexadecimal value
37 *
38 * @pure
39 */
40 public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
41
42 /**
43 * Converts a timestamp extracted from a UUID to a Unix timestamp
44 *
45 * @param Hexadecimal $uuidTimestamp A hexadecimal representation of a UUID timestamp; a UUID timestamp is a count
46 * of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582.
47 *
48 * @return Time An instance of {@see Time}
49 *
50 * @pure
51 */
52 public function convertTime(Hexadecimal $uuidTimestamp): Time;
53 }