PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 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 All 36 releases
media-cloud-sync / includes / sdk / google / ramsey / uuid / src / Rfc4122 / VersionTrait.php

VersionTrait.php in Media Cloud Sync 1.4.2, at includes/sdk/google/ramsey/uuid/src/Rfc4122/VersionTrait.php

69 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 declare (strict_types=1);
13 namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Rfc4122;
14
15 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Uuid;
16 /**
17 * Provides common functionality for handling the version, as defined by RFC 9562 (formerly RFC 4122)
18 *
19 * @immutable
20 */
21 trait VersionTrait
22 {
23 /**
24 * Returns the UUID version
25 *
26 * The version number describes how the UUID was generated and has the following meaning:
27 *
28 * 1. Gregorian time UUID
29 * 2. DCE security UUID
30 * 3. Name-based UUID hashed with MD5
31 * 4. Randomly generated UUID
32 * 5. Name-based UUID hashed with SHA-1
33 * 6. Reordered Gregorian time UUID
34 * 7. Unix Epoch time UUID
35 * 8. Custom format UUID
36 *
37 * This returns `null` if the UUID is not an RFC 9562 (formerly RFC 4122) variant, since the version is only
38 * meaningful for this variant.
39 *
40 * @link https://www.rfc-editor.org/rfc/rfc9562#section-4.2 RFC 9562, 4.2. Version Field
41 *
42 * @pure
43 */
44 public abstract function getVersion() : ?int;
45 /**
46 * Returns true if these fields represent a max UUID
47 */
48 public abstract function isMax() : bool;
49 /**
50 * Returns true if these fields represent a nil UUID
51 */
52 public abstract function isNil() : bool;
53 /**
54 * Returns true if the version matches one of those defined by RFC 9562 (formerly RFC 4122)
55 *
56 * @return bool True if the UUID version is valid, false otherwise
57 */
58 private function isCorrectVersion() : bool
59 {
60 if ($this->isNil() || $this->isMax()) {
61 return \true;
62 }
63 return match ($this->getVersion()) {
64 Uuid::UUID_TYPE_TIME, Uuid::UUID_TYPE_DCE_SECURITY, Uuid::UUID_TYPE_HASH_MD5, Uuid::UUID_TYPE_RANDOM, Uuid::UUID_TYPE_HASH_SHA1, Uuid::UUID_TYPE_REORDERED_TIME, Uuid::UUID_TYPE_UNIX_TIME, Uuid::UUID_TYPE_CUSTOM => \true,
65 default => \false,
66 };
67 }
68 }
69