Ben Ramsey
b21cb6d655
fix: max UUID should be variant 7, nil UUID should be variant 0
2025-05-31 20:12:03 -05:00
Ben Ramsey
76cbc566e2
chore(deps-dev): upgrade PHPStan
2025-05-25 16:52:53 -05:00
Maximilian Bösing
bf2bee216a
Add explicit Stringable interface to UuidInterface ( #491 )
...
Even tho, the `Stringable` interface is implicit on all objects containing the method `__toString`, it is recommended by PHP to explicitly setting that interface.
From php.net documentation:
> [...] Unlike most interfaces, **Stringable** is implicitly present on any class that has the magic `__toString()` method defined, although it can and should be declared explicitly.
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com >
2023-02-07 10:14:23 -06:00
Marcel Berteler
5e24bfd390
feat: add Uuid:fromHexadecimal() ( #309 )
...
Co-authored-by: mberteler <marcel.berteler@capetown.gov.za >
Co-authored-by: Ben Ramsey <ben@benramsey.com >
2022-12-19 15:18:32 -06:00
Ben Ramsey
55d8833b06
feat: support version 8, custom UUIDs
2022-11-05 17:57:29 -05:00
Ben Ramsey
0ba1ffb029
fix: ensure monotonicity for version 7 UUIDs
2022-11-05 16:29:26 -05:00
Ben Ramsey
685c2f3f23
feat: support max UUIDs
2022-09-14 20:44:24 -05:00
Ben Ramsey
4f4deb1dd6
feat: add UUIDv7 documentation and customization
2022-09-14 18:21:10 -05:00
Ben Ramsey
aa1e488afa
feat: support version 7 (Unix Epoch time) UUIDs
2022-09-13 22:13:33 -05:00
Ben Ramsey
f1891183f9
Upgrade PHPStan
2022-08-05 14:46:56 -05:00
hubipe
e3e9179f27
LazyUuidFromString for valid UUIDs in uppercase ( #401 )
2022-01-29 13:05:59 -06:00
Chris Smith
ef1eb74c82
Add test covering Uuid::fromString() being called with empty string
2021-08-09 12:55:31 +01:00
Ben Ramsey
d7379b67af
test: update exception message for PHP 8.1
2021-08-06 14:35:42 -05:00
Ben Ramsey
c005f69d6e
chore: update package files
2021-08-06 14:05:57 -05:00
Bilge
7947413a76
Use assertSame instead of assertEquals.
2020-08-23 13:53:19 +01:00
Marco Pivetta
b805572537
Ensure that Uuid::uuidX() generators produce instances equivalent to Uuid::fromString() and Uuid::fromBytes()
...
With this change, `Uuid::uuid1()`, `Uuid::uuid2()` and so forth now produce a `LazyUuidFromString` instance, which
is both more memory efficient and comparable to `Uuid::fromString()` instances in other tools, such as within
PHPUnit's `Assertion::assertEqual()`, which would reject any two objects not matching each other's types.
Before this patch, `Assertion::assertEquals(Uuid::uuid5(...), Uuid::fromString(...))` would always fail due to
different subtypes produced by the two factory methods.
2020-07-09 13:57:30 +02:00
Marco Pivetta
1f0cd71d93
Applied fixes and suppressions (sadly) to match psalm/phpstan code quality guidelines
...
We have a lot of deprecated API in here which shouldn't exist in first place, but that
will luckily disappear with v5.0.0 :-)
2020-07-09 13:57:30 +02:00
Marco Pivetta
1ce3f55673
Applied automated CS fixes according to project CS settings
2020-07-09 13:57:30 +02:00
Marco Pivetta
569e93ac4e
Re-implemented Uuid::fromString() so it produces a LazyUuidFromString when possible
...
This should speed up `Uuid::fromString()` massively, leading to much shallower execution
paths when `toString()` and similar simplistic API is required.
2020-07-09 13:57:30 +02:00
Ben Ramsey
22ee596348
Make serialize(UuidInterface) more compact
...
Resolves #318
2020-07-08 15:27:19 -05:00
Ben Ramsey
ba7c1c17ce
Add more tests for UuidV6
2020-02-24 15:14:57 -06:00
Ben Ramsey
fec93008bc
Accept Type\Hexadecimal for the first parameter to uuid1()
2020-02-24 14:34:40 -06:00
Ben Ramsey
ab3c89fb8e
Change the $node parameter from mixed to ?Hexadecimal
2020-02-24 13:44:03 -06:00
Ben Ramsey
cc2bf6f8ef
Support version 6 UUIDs
...
See the following:
* https://github.com/uuid6/uuid6-ietf-draft
* http://gh.peabody.io/uuidv6/
2020-02-22 22:41:15 -06:00
Ben Ramsey
65b0c091c0
Deprecate VALID_PATTERN, UUID_TYPE_IDENTIFIER; suggest replacements
2020-02-21 13:37:06 -06:00
Ben Ramsey
a7cf07a2d8
Fix microsecond rounding error on 32-bit systems
2020-02-21 02:51:31 -06:00
Ben Ramsey
e0ff858ff6
Return Hexadecimal from getHex() and IntegerValue from getInteger()
2020-02-21 01:40:14 -06:00
Ben Ramsey
7af4814017
Round microseconds to six digits when getting DateTime from v1 UUIDs
2020-02-21 01:17:05 -06:00
Ben Ramsey
4a44aeab2e
Add a test for the Unix epoch with v1 UUIDs
2020-02-20 17:23:32 -06:00
Ben Ramsey
5f0850c7b5
Add an additional test for last possible date for a v1 UUID
2020-02-20 17:03:08 -06:00
Ben Ramsey
fb4f54fb84
Address static analysis issues
2020-02-08 13:14:17 -06:00
Ben Ramsey
0bff9e8660
Add NameGeneratorInterface and generators for v3 and v5 UUIDs
2020-02-08 13:12:20 -06:00
Marco Pivetta
a252f29847
Import used functions and constants via use statement to disallow ambiguity for compiler/static-analysis
...
As documented in https://wiki.php.net/rfc/use_global_elements , the engine (by default) does a local namespace
lookup, then falls back to global namespace when first calling a global function referenced in namespaced code,
unless that function is referenced via fully qualified name (FQN).
By using the FQN, the actual symbol can be looked up at compile-time, both by the PHP engine and by static analysis
tooling, allowing for compiler (in particular) optimizations to replace known hot-path functions with specialized opcodes.
Sadly, no actual benchmark at hand: the improvements can be minimal or massive, depending on where this library is
used (tight loops being most relevant).
2020-02-03 13:15:35 -06:00
Ben Ramsey
5fa4eb4f17
Add fromDateTime() to create version 1 UUIDs from DateTime instances
...
Fixes #28
2020-02-03 00:48:41 -06:00
Ben Ramsey
a5c7314f8d
Fix string passed to DateTimeImmutable
2020-01-20 21:04:26 -06:00
Ben Ramsey
a8d52100de
Support microtime in returned DateTimeInterface instances
...
Fixes #90 and supersedes #93 .
2020-01-19 23:21:48 -06:00
Ben Ramsey
268e66aad8
Add static Uuid::uuid2() method
2020-01-18 14:14:47 -06:00
Ben Ramsey
8202946225
Add NilUuid concrete class to represent nil UUIDs
2020-01-18 12:14:01 -06:00
Ben Ramsey
d21a3e3875
Add tests to ensure static methods return specific UUID types
2020-01-18 12:14:01 -06:00
Ben Ramsey
5d1f106882
Rename Validator\Validator to Validator\GenericValidator
2020-01-18 12:14:00 -06:00
Ben Ramsey
2ad77d9ca7
Remove CalculatorInterface as a Uuid constructor parameter
2020-01-18 12:14:00 -06:00
Ben Ramsey
360261d617
Deprecate all the fields methods on UuidInterface and Uuid
2020-01-18 12:14:00 -06:00
Ben Ramsey
10624f64a1
Change return type of Uuid::getFields() to FieldsInterface
2020-01-18 12:14:00 -06:00
Ben Ramsey
c11c023796
Address static analysis issues and add additional tests
2020-01-18 12:13:59 -06:00
Ben Ramsey
f5cfb5f57d
Split known v3 and v5 UUID tests into providers
2020-01-18 12:13:59 -06:00
Ben Ramsey
d543895369
Return string integers instead of int integers
2020-01-18 12:13:58 -06:00
Ben Ramsey
63942c393d
Remove Gmp converters; the generic converters are preferred
2020-01-18 12:13:58 -06:00
Ben Ramsey
ebaa04a6b2
Improve coverage and unit tests for fields, GUIDs, and nonstandard UUIDs
2020-01-18 12:13:57 -06:00
Ben Ramsey
70eace9086
Introduce separate classes to handle nonstandard UUIDs
2020-01-18 12:13:57 -06:00
Ben Ramsey
d6ed9b3832
Introduce separate class support for GUIDs
2020-01-18 12:13:57 -06:00