uuid.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .. _reference.uuid:
  2. ====
  3. Uuid
  4. ====
  5. Ramsey\Uuid\Uuid provides static methods for the most common functionality for
  6. generating and working with UUIDs. It also provides constants used throughout
  7. the ramsey/uuid library.
  8. .. php:namespace:: Ramsey\Uuid
  9. .. php:class:: Uuid
  10. .. php:const:: UUID_TYPE_TIME
  11. :ref:`rfc4122.version1` UUID.
  12. .. php:const:: UUID_TYPE_DCE_SECURITY
  13. :ref:`rfc4122.version2` UUID.
  14. .. php:const:: UUID_TYPE_HASH_MD5
  15. :ref:`rfc4122.version3` UUID.
  16. .. php:const:: UUID_TYPE_RANDOM
  17. :ref:`rfc4122.version4` UUID.
  18. .. php:const:: UUID_TYPE_HASH_SHA1
  19. :ref:`rfc4122.version5` UUID.
  20. .. php:const:: UUID_TYPE_REORDERED_TIME
  21. :ref:`rfc4122.version6` UUID.
  22. .. php:const:: UUID_TYPE_PEABODY
  23. *Deprecated.* Use :php:const:`Uuid::UUID_TYPE_REORDERED_TIME` instead.
  24. .. php:const:: UUID_TYPE_UNIX_TIME
  25. :ref:`rfc4122.version7` UUID.
  26. .. php:const:: NAMESPACE_DNS
  27. The name string is a fully-qualified domain name.
  28. .. php:const:: NAMESPACE_URL
  29. The name string is a URL.
  30. .. php:const:: NAMESPACE_OID
  31. The name string is an `ISO object identifier (OID)`_.
  32. .. php:const:: NAMESPACE_X500
  33. The name string is an `X.500`_ `DN`_ in `DER`_ or a text output format.
  34. .. php:const:: NIL
  35. The nil UUID is a special form of UUID that is specified to have all 128
  36. bits set to zero.
  37. .. php:const:: DCE_DOMAIN_PERSON
  38. DCE Security principal (person) domain.
  39. .. php:const:: DCE_DOMAIN_GROUP
  40. DCE Security group domain.
  41. .. php:const:: DCE_DOMAIN_ORG
  42. DCE Security organization domain.
  43. .. php:const:: RESERVED_NCS
  44. Variant identifier: reserved, NCS backward compatibility.
  45. .. php:const:: RFC_4122
  46. Variant identifier: the UUID layout specified in RFC 4122.
  47. .. php:const:: RESERVED_MICROSOFT
  48. Variant identifier: reserved, Microsoft Corporation backward compatibility.
  49. .. php:const:: RESERVED_FUTURE
  50. Variant identifier: reserved for future definition.
  51. .. php:staticmethod:: uuid1([$node[, $clockSeq]])
  52. Generates a version 1, Gregorian time UUID. See :ref:`rfc4122.version1`.
  53. :param Ramsey\\Uuid\\Type\\Hexadecimal|null $node: An optional hexadecimal node to use
  54. :param int|null $clockSeq: An optional clock sequence to use
  55. :returns: A version 1 UUID
  56. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV1
  57. .. php:staticmethod:: uuid2($localDomain[, $localIdentifier[, $node[, $clockSeq]]])
  58. Generates a version 2, DCE Security UUID. See :ref:`rfc4122.version2`.
  59. :param int $localDomain: The local domain to use (one of :php:const:`Uuid::DCE_DOMAIN_PERSON`, :php:const:`Uuid::DCE_DOMAIN_GROUP`, or :php:const:`Uuid::DCE_DOMAIN_ORG`)
  60. :param Ramsey\\Uuid\\Type\\Integer|null $localIdentifier: A local identifier for the domain (defaults to system UID or GID for *person* or *group*)
  61. :param Ramsey\\Uuid\\Type\\Hexadecimal|null $node: An optional hexadecimal node to use
  62. :param int|null $clockSeq: An optional clock sequence to use
  63. :returns: A version 2 UUID
  64. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV2
  65. .. php:staticmethod:: uuid3($ns, $name)
  66. Generates a version 3, name-based (MD5) UUID. See :ref:`rfc4122.version3`.
  67. :param Ramsey\\Uuid\\UuidInterface|string $ns: The namespace for this identifier
  68. :param string $name: The name from which to generate an identifier
  69. :returns: A version 3 UUID
  70. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV3
  71. .. php:staticmethod:: uuid4()
  72. Generates a version 4, random UUID. See :ref:`rfc4122.version4`.
  73. :returns: A version 4 UUID
  74. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV4
  75. .. php:staticmethod:: uuid5($ns, $name)
  76. Generates a version 5, name-based (SHA-1) UUID. See :ref:`rfc4122.version5`.
  77. :param Ramsey\\Uuid\\UuidInterface|string $ns: The namespace for this identifier
  78. :param string $name: The name from which to generate an identifier
  79. :returns: A version 5 UUID
  80. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV5
  81. .. php:staticmethod:: uuid6([$node[, $clockSeq]])
  82. Generates a version 6, reordered time UUID. See :ref:`rfc4122.version6`.
  83. :param Ramsey\\Uuid\\Type\\Hexadecimal|null $node: An optional hexadecimal node to use
  84. :param int|null $clockSeq: An optional clock sequence to use
  85. :returns: A version 6 UUID
  86. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV6
  87. .. php:staticmethod:: uuid7([$dateTime])
  88. Generates a version 7, Unix Epoch time UUID. See :ref:`rfc4122.version7`.
  89. :param DateTimeInterface|null $dateTime: The date from which to create the UUID instance
  90. :returns: A version 7 UUID
  91. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV7
  92. .. php:staticmethod:: fromString($uuid)
  93. Creates an instance of UuidInterface from the string standard
  94. representation.
  95. :param string $uuid: The string standard representation of a UUID
  96. :returntype: Ramsey\\Uuid\\UuidInterface
  97. .. php:staticmethod:: fromBytes($bytes)
  98. Creates an instance of UuidInterface from a 16-byte string.
  99. :param string $bytes: A 16-byte binary string representation of a UUID
  100. :returntype: Ramsey\\Uuid\\UuidInterface
  101. .. php:staticmethod:: fromInteger($integer)
  102. Creates an instance of UuidInterface from a 128-bit string integer.
  103. :param string $integer: A 128-bit string integer representation of a UUID
  104. :returntype: Ramsey\\Uuid\\UuidInterface
  105. .. php:staticmethod:: fromDateTime($dateTime[, $node[, $clockSeq]])
  106. Creates a version 1 UUID instance from a `DateTimeInterface
  107. <https://www.php.net/datetimeinterface>`_ instance.
  108. :param DateTimeInterface $dateTime: The date from which to create the UUID instance
  109. :param Ramsey\\Uuid\\Type\\Hexadecimal|null $node: An optional hexadecimal node to use
  110. :param int|null $clockSeq: An optional clock sequence to use
  111. :returns: A version 1 UUID
  112. :returntype: Ramsey\\Uuid\\Rfc4122\\UuidV1
  113. .. php:staticmethod:: isValid($uuid)
  114. Validates the string standard representation of a UUID.
  115. :param string $uuid: The string standard representation of a UUID
  116. :returntype: ``bool``
  117. .. php:staticmethod:: setFactory($factory)
  118. Sets the factory used to create UUIDs.
  119. :param Ramsey\\Uuid\\UuidFactoryInterface $factory: A UUID factory to use for all UUID generation
  120. :returntype: void
  121. .. _ISO object identifier (OID): http://www.oid-info.com
  122. .. _X.500: https://en.wikipedia.org/wiki/X.500
  123. .. _DN: https://en.wikipedia.org/wiki/Distinguished_Name
  124. .. _DER: https://www.itu.int/rec/T-REC-X.690/